问题描述
绑定到视图模型的xaml属性仅在加载UI后才获取值,在任何更改下,不会引发Raise属性更改事件,也不会使用最新值进行更新。
我还有一个xaml,其实现与预期的相同,但是唯一的不同是此xaml包含数据模板,因为该视图模型中的所有属性均不会触发Raise属性更改事件并在发生任何更改时更新用户界面。
这是我在视图模型中的财产
public bool IsDataValid
{
get
{return isDattaValid;}
set
{
isDattaValid = value;
RaisePropertyChangedEvent("IsDataValid");
}
}
这是我的xaml
<Expander Grid.Row="6" x:Name="AdvanceSettingsExpander">
<Expander.Resources>
<DataTemplate x:Key="serviceTemplateKey">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0,6,0" Foreground="Red" Text= "!"
Visibility="{Binding IsDataValid,Converter={StaticResource BoolToVisibilityConv},Mode=TwoWay,NotifyOnTargetUpdated=True,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Margin="0,0" Text="Advance Settings for "></TextBlock>
<TextBlock Margin="0,0" Text=":"></TextBlock>
<TextBlock Margin="0,0"
Text="{Binding Path=Name}" Width="Auto"></TextBlock>
</StackPanel>
</DataTemplate>
</Expander.Resources>
<Expander.Header>
<ContentControl Content="{Binding Path=ConfiguredServices}"
ContentTemplate="{StaticResource serviceTemplateKey}">
</ContentControl>
</Expander.Header>
<ContentControl
Content="{Binding Path=RemDevAdvanceSettingHostingContent}"
IsEnabled="{Binding Path=IsAdvConfigAllowed}"
Margin="4,0" Height="Auto"/>
</Expander>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)