wpf - WPF 绑定未引发数据模板类型扩展器的属性更改事件
问题描述
绑定到视图模型的 xaml 属性仅在加载 UI 后获取值,在任何更改时,不会引发 Raise 属性更改事件并且不会使用最新值更新。
我还有一个 xaml,其中相同的实现按预期工作,但唯一的区别是此 xaml 包含数据模板,因为此视图模型中的所有属性都不会触发 Raise property changed 事件并在任何更改时更新 UI。
这是我在视图模型中的属性
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,0,6,0" Foreground="Red" Text= "!"
Visibility="{Binding IsDataValid, Converter={StaticResource BoolToVisibilityConv}, Mode=TwoWay, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Margin="0,0,6,0" Text="Advance Settings for "></TextBlock>
<TextBlock Margin="0,0,6,0" Text=":"></TextBlock>
<TextBlock Margin="0,0,6,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,0,0" Height="Auto"/>
</Expander>
解决方案
推荐阅读
- r - Leaflet r地图保存问题
- javascript - Javascript appendChild 不适用于 li 元素
- linux - 以 iso 格式创建 OS 映像
- reactjs - import & export may only appear at the top level - CRA React App with Typescript
- angularjs - AngularJs ui-router 成功过渡获取控制器
- google-cloud-platform - 从云功能插入扳手的会话泄漏
- sapjco3 - SAPJCo 是特定于 SAP 安装还是可以在不同的 SAP Box 之间重复使用?
- javascript - 为什么第二次迭代后 b 的值会自行增加?
- wordpress - 防止 CMS 识别
- javascript - 检查您是从主页还是子页面重定向的方法