用法1:
<DataGridTemplateColumn Header="{lex:LocText ExamineRoom}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Name="tb" Text="{Binding ExamineRoom}"> </TextBlock> <DataTemplate.Triggers> <DataTrigger Value="False"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource OnlineRoomCoverter}"> <Binding Path="DataContext.OnlineRooms" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=DataGrid}" /> <Binding Path="ExamineRoom" /> </MultiBinding> </DataTrigger.Binding> <Setter TargetName="tb" Property="Foreground" Value="Red" /> <Setter TargetName="tb" Property="ToolTip" Value="{lex:LocText RoomNotOnline}" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn>
用法2:
<DataGridTemplateColumn Header="{lex:LocText ExamineRoom}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Name="tb" Text="{Binding ExamineRoom}"> <TextBlock.Style> <Style TargetType="TextBlock"> <Style.Triggers> <DataTrigger Value="False"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource OnlineRoomCoverter}"> <Binding Path="DataContext.OnlineRooms" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=DataGrid}" /> <Binding Path="ExamineRoom" /> </MultiBinding> </DataTrigger.Binding> <Setter Property="Foreground" Value="Red" /> <Setter Property="ToolTip" Value="{lex:LocText RoomNotOnline}" /> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn>
时间: 2024-10-09 14:57:31