开发者

Current Time Not working in WPF DLL [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜