Last active
May 3, 2022 23:26
-
-
Save HakanL/c845a3d8921c76f884c8703a97c385ee to your computer and use it in GitHub Desktop.
XAML UserControl showing ListView with DataTrigger for boolean replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UserControl x:Class="TestApplication.UserControl1" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
mc:Ignorable="d" | |
d:DesignHeight="450" d:DesignWidth="800"> | |
<ListView> | |
<ListView.View> | |
<GridView> | |
<GridViewColumn Width="50" Header="Rec. No" DisplayMemberBinding="{Binding RecordNo}" /> | |
<GridViewColumn Width="100" Header="Value" DisplayMemberBinding="{Binding Value, StringFormat=\{0:N0\} dB}" /> | |
<GridViewColumn Width="120" Header="BoolTest1"> | |
<GridViewColumn.CellTemplate> | |
<DataTemplate> | |
<TextBlock> | |
<TextBlock.Style> | |
<Style TargetType="{x:Type TextBlock}"> | |
<Setter Property="Text" Value="No" /> | |
<Style.Triggers> | |
<DataTrigger Binding="{Binding BoolProperty1}" Value="True"> | |
<Setter Property="Text" Value="Yes" /> | |
</DataTrigger> | |
</Style.Triggers> | |
</Style> | |
</TextBlock.Style> | |
</TextBlock> | |
</DataTemplate> | |
</GridViewColumn.CellTemplate> | |
</GridViewColumn> | |
<GridViewColumn Width="110" Header="BoolTest2"> | |
<GridViewColumn.CellTemplate> | |
<DataTemplate> | |
<TextBlock> | |
<TextBlock.Style> | |
<Style TargetType="{x:Type TextBlock}"> | |
<Setter Property="Text" Value="No" /> | |
<Style.Triggers> | |
<DataTrigger Binding="{Binding BoolProperty2}" Value="True"> | |
<Setter Property="Text" Value="Yes" /> | |
</DataTrigger> | |
</Style.Triggers> | |
</Style> | |
</TextBlock.Style> | |
</TextBlock> | |
</DataTemplate> | |
</GridViewColumn.CellTemplate> | |
</GridViewColumn> | |
</GridView> | |
</ListView.View> | |
</ListView> | |
</UserControl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment