2010-05-29 39 views
2

我正在WPF,C#中的DLL,我在VC++中使用它。当前时间不工作在WPF DLL

在那个DLL中,我有一个textblock来显示当前时间,当我将WPF应用程序作为Windows应用程序运行时,它会正确显示当前时间,并且还会用新计时更新。

但是,当我在VC++应用程序中使用它作为DLL时,当前时间没有得到更新。它显示了applcaiton被加载的时间,就这些。

它没有得到更新。

代码:

public Button() 
     { 
      InitializeComponent(); 
      DispatcherTimer dispatcherTimer = new DispatcherTimer(); 
      dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); 
      dispatcherTimer.Interval = new TimeSpan(0, 0, 1); 
      dispatcherTimer.Start(); 
     } 
     private void dispatcherTimer_Tick(object sender, EventArgs e) 
     {  
      DataContext = DateTime.Now.ToString("g");      

     } 

XAML:

<TextBlock Margin="0,6,211,0" Name="textBlock1" Text="{Binding}"/> 

回答

0

那是我的错误。 我没有正确地构建解决方案。 现在它的工作。