zoukankan      html  css  js  c++  java
  • WPF DataTriger 用法示例代码

    用法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>
  • 相关阅读:
    【非技术】谈谈业务6W+H
    WinForm二三事(三)Control.Invoke&Control.BeginInvoke
    企业应用架构模式读书笔记(一)
    WinForm二三事(四)界面布局(上)
    WinForm二三事(二)异步操作
    WinForm二三事(一)消息循环
    白话基础之虚拟存储器
    不清楚自己的位置,会走很多弯路
    WinForm二三事(一)补遗
    技术、业务、市场
  • 原文地址:https://www.cnblogs.com/karl-F/p/8081607.html
Copyright © 2011-2022 走看看