【发布时间】:2014-01-19 17:30:59
【问题描述】:
我是 WPF 的新手,遇到了一个我似乎找不到解决方案的问题。
我正在编写一个 G19(键盘)小程序。此键盘附带一个 320x240 显示屏,您可以使用 C# 访问它。
我为此使用 WPF,因为我不再需要进行任何 GDI 绘图,而是使用普通控件。
所以。它按我的意愿工作。除了一个 UserControl 之外,一切都正确绘制。我已经下载了这个控件->http://marqueedriproll.codeplex.com/
在设计器中,控件有效,Loaded 事件被触发并且动画效果很好。 当我运行我的应用程序时,我只看到标签和文本。动画不起作用,并且 Loaded 事件不再触发。
感谢任何帮助。
主要功能是我的包装器。包装器已经是一个用户控件并显示可切换的插件。此包装器具有框架控件(Wrapper1)。每次切换插件时,我都会替换此框架的内容。
public void SetPlugin(IPlugin plugin)
{
if (this.MainPlugin != null)
{
this.MainPlugin.OnHide();
((UserControl)this.MainPlugin).Visibility = System.Windows.Visibility.Hidden;
}
this.MainPlugin = plugin;
((UserControl)this.MainPlugin).Visibility = System.Windows.Visibility.Visible;
this.MainPlugin.OnShow();
this.Wrapper1.Content = this.MainPlugin;
}
我认为以这种方式处理插件系统是正确的方法。插件在我的键盘上绘制。
我不明白为什么用户控件只能在设计器视图中工作,而不是在正在运行的应用程序中。
滚动标签的基本代码是这样的:
public MarqueeText()
{
this.Loaded += new RoutedEventHandler(MarqueeText_Loaded);
InitializeComponent();
canMain.Height = this.Height;
canMain.Width = this.Width;
}
void MarqueeText_Loaded(object sender, RoutedEventArgs e)
{
StartMarqueeing(_marqueeType);
}
我看不出它不起作用的原因。其实我总能找到解决问题的方法,但这次我什么也没看到。
提前致谢。今天真的需要你的帮助。 祝你星期六愉快! :)
【问题讨论】: