【问题标题】:Howto initialize a OneWayToSource property in XAML如何在 XAML 中初始化 OneWayToSource 属性
【发布时间】:2017-01-09 23:54:44
【问题描述】:
   <dxe:CheckEdit x:Name="something" 
                  IsChecked="{Binding IsSomething, 
                              Mode=OneWayToSource, 
                              UpdateSourceTrigger=PropertyChanged}"/>

我想用True 初始化属性IsChecked

我的 ViewModel 做不到。

我不想在后面的代码中这样做。

我不知道如何在 XAML 中执行此操作,但我相信这样做是正确的。

【问题讨论】:

  • 为什么你不能在你的 ViewModel 中做到这一点?
  • @Myriam,因为 ViewModel 属性的 ViewModel 初始化将在视图构造过程中被默认值 False 覆盖。

标签: wpf xaml dependency-properties


【解决方案1】:

尝试将 Binding 的 Fallback 值设置为 True:

<dxe:CheckEdit x:Name="something" IsChecked="{Binding IsSomething, 
                              Mode=OneWayToSource, 
                              UpdateSourceTrigger=PropertyChanged, FallbackValue=True}"/>

【讨论】:

    猜你喜欢
    • 2010-10-14
    • 2013-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-15
    • 2022-10-06
    • 2014-08-27
    相关资源
    最近更新 更多