【发布时间】:2015-09-22 22:05:55
【问题描述】:
我将我的应用程序从 WP 8.1 / W 8.1 转换为 UWP。它包括一个更新文本框值的计时器。这是 XAML:
Text="{Binding CurrentLocalDateTime, Mode=TwoWay, Converter={StaticResource DateTimeConverter}}"
还有数据上下文:
private DateTime currentLocalDateTime;
public DateTime CurrentLocalDateTime { get { return currentLocalDateTime; } set { currentLocalDateTime = value; OnPropertyChanged("CurrentLocalDateTime"); } }
private void TimerExecution(object sender, object e)
{
CurrentLocalDateTime = DateTime.Now;
}
我想使用新的 x:Bind 绑定方式,但控件永远不会更新,使用以下代码:
Text="{x:Bind CurrentLocalDateTime, Mode=TwoWay, Converter={StaticResource DateTimeConverter}}"
数据上下文:
public DateTime CurrentLocalDateTime { get; set; }
private void TimerExecution(object sender, object e)
{
CurrentLocalDateTime = DateTime.Now;
}
怎么了?
非常感谢您的帮助。 问候
【问题讨论】:
标签: c# windows binding windows-10 uwp