我有一个层次结构绑定到实体框架模型的树视图。下面的矩形仅适用于初始加载。并且当我触发 Propertychanged 事件时不更新其颜色等。<HierarchicalDataTemplate ItemsSource="{Binding tblLines}"> <StackPanel Orientation="Horizontal" Margin="2"> <Image Height="15" Margin="4" x:Name="imgTreeProject" Source="/DES STUDIO PR;component/Resources/Images/folder_closed.png"/> <TextBlock Text="{Binding Name}" Margin ="8" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"/> <Rectangle Name="X" Width="10" Height="10" Fill="{Binding Path=.,Converter={StaticResource CheckoutConverter},UpdateSourceTrigger=PropertyChanged}" ToolTip="{Binding Path=.,Converter={StaticResource CheckoutPersonConverter},UpdateSourceTrigger=PropertyChanged}" ToolTipService.IsEnabled="{Binding Path=.,Converter={StaticResource CheckoutToolTipVis},UpdateSourceTrigger=PropertyChanged}"/> </StackPanel>这是我的转换器:public class CheckoutConverter : IValueConverter{ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is TblBase) { var Baseentity = value as TblBase; if (Baseentity.COID == MainWindow.LocalUser.ID) { return Brushes.Green; } else if ((Baseentity.COID == 0) || (Baseentity.COID == null)) { return Brushes.Transparent; } else if (Baseentity.COID != 0) { return Brushes.Black; } } return Brushes.Black; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }}属性更改事件适用于不使用转换器的树视图绑定,因此我不确定我缺少什么。
1 回答
- 1 回答
- 0 关注
- 112 浏览
添加回答
举报
0/150
提交
取消