我有一个包含我想隐藏如果在一个视图模型的一个的属性值是true图像一个DataTemplate。谁能告诉我,为什么下面的XAML不起作用?
<图像X:NAME =IMG来源=.. \\影像\\ List_16.png保证金=0,0,5,0> < Image.Style> <样式和GT; < Style.Triggers> < DataTrigger绑定={结合CurrentListHasPendingChanges}VALUE =真> < setter属性=Image.VisibilityVALUE =隐藏/> < / DataTrigger> < DataTrigger绑定={结合CurrentListHasPendingChanges}VALUE =FALSE> < setter属性=Image.VisibilityVALUE =可见/> < / DataTrigger> < /Style.Triggers> < /样式和GT; < /Image.Style>< /图像>解决方案
这不就是
< setter属性=能见度VALUE =隐藏/>
我假设你使用INotifyProptyChanged。
修改我做了一些谷歌搜索,我认为你需要使用某种模板,以使触发器的工作。
例如:的social.msdn.microsoft/Forums/en-US/wpf/thread/ae2dbfb7-5dd6-4352-bfa1-53634289329d
www.thejoyof$c$c/Help%5FWhy%5Fcant%5FI%5Fuse%5FDataTriggers%5Fwith%5Fcontrols%5Fin%5FWPF.aspx
I have a datatemplate containing an image that I want to be hidden if the the value of a property in a ViewModel is true. Can anyone tell me why the the xaml below does not work?
<Image x:Name="img" Source="..\Images\List_16.png" Margin="0,0,5,0"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding CurrentListHasPendingChanges}" Value="True"> <Setter Property="Image.Visibility" Value="Hidden" /> </DataTrigger> <DataTrigger Binding="{Binding CurrentListHasPendingChanges}" Value="False"> <Setter Property="Image.Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image>解决方案
isn't that
<Setter Property="Visibility" Value="Hidden" />?
I assume you use INotifyProptyChanged.
EDIT I did some Googling and I think you need to use some sort of template in order to make the trigger work.
eg.: social.msdn.microsoft/Forums/en-US/wpf/thread/ae2dbfb7-5dd6-4352-bfa1-53634289329d
www.thejoyofcode/Help%5FWhy%5Fcant%5FI%5Fuse%5FDataTriggers%5Fwith%5Fcontrols%5Fin%5FWPF.aspx
更多推荐
WPF触发器结合MVVM财产
发布评论