码迷,mamicode.com
首页 > Windows程序 > 详细

WPF DataTriger 用法示例代码

时间:2017-12-21 18:14:22      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:online   oct   style   temp   converter   type   pre   binding   targe   

用法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>

 

WPF DataTriger 用法示例代码

标签:online   oct   style   temp   converter   type   pre   binding   targe   

原文地址:http://www.cnblogs.com/karl-F/p/8081607.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!