Current Time Not working in WPF DLL [closed]
I'm making a DLL in WPF, C# and I'm using it in VC++.
In that DLL I have one textblock to display current time, and when I run the WPF application as a Windows application it shows current time correctly and also updated with new timings.
But when I use it as Dll in VC++ applcat开发者_StackOverflow中文版ion, the current time is not getting updated. It shows the time when the applcaiton is loaded, that's all.
It's not get updated.
Code:
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}"/>
Thats my mistake. I didnt properly build the solution. Now its working.
精彩评论