99 lines
6.3 KiB
XML
99 lines
6.3 KiB
XML
<UserControl x:Class="JD.Rosetta.Module.Controls.CheckBoxList"
|
|
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"
|
|
xmlns:local="clr-namespace:JD.Rosetta.Module.Controls"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="450" d:DesignWidth="800">
|
|
|
|
<UserControl.Resources>
|
|
<ResourceDictionary>
|
|
<Thickness x:Key="CheckboxToContentPadding" Left="8" Top="1" Right="0" Bottom="0"/>
|
|
</ResourceDictionary>
|
|
</UserControl.Resources>
|
|
|
|
<!-- To ensure the first box and the list are on the same column and get everything in one panel -->
|
|
<StackPanel x:Name="GlobalStackPanel" Orientation="Vertical" Margin="0,0,0,20" HorizontalAlignment="Stretch" SizeChanged="GlobalStackPanel_OnSizeChanged"
|
|
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CheckBoxList}}">
|
|
<StackPanel x:Name="CheckOrUncheckAllBoxStackPanel" Orientation="Horizontal" Margin="10,10,0,10"
|
|
SizeChanged="CheckOrUncheckAllBoxStackPanel_OnSizeChanged">
|
|
<CheckBox x:Name="CheckOrUncheckAllBox" IsChecked="{Binding AreAllBoxesCheckedOrUnchecked}"
|
|
IsThreeState="True" VerticalAlignment="Center" Padding="{StaticResource CheckboxToContentPadding}">
|
|
<TextBlock Text="{Binding CheckOrUncheckAllBoxesText}" FontSize="16">
|
|
<TextBlock.Style>
|
|
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
|
|
<Setter Property="FontWeight" Value="Normal"/>
|
|
<Setter Property="LayoutTransform">
|
|
<Setter.Value>
|
|
<!-- Scale up on the whole checkbox, scale down on the text so that it's not aliased -->
|
|
<!-- Done this way rather than overriding the template because keeping the presentation and style was too much hassle -->
|
|
<ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
|
|
</Setter.Value>
|
|
</Setter>
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Path=IsChecked, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}}" Value="True">
|
|
<Setter Property="FontWeight" Value="ExtraBold"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
</TextBlock>
|
|
<CheckBox.Style>
|
|
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource {x:Type CheckBox}}">
|
|
<Setter Property="FontWeight" Value="Normal"/>
|
|
<Setter Property="LayoutTransform">
|
|
<Setter.Value>
|
|
<ScaleTransform ScaleX="1.25" ScaleY="1.25"/>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</CheckBox.Style>
|
|
</CheckBox>
|
|
</StackPanel>
|
|
|
|
<ItemsControl ItemsSource="{Binding ItemStates}">
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<CheckBox x:Name="ItemCheckBox" IsChecked="{Binding IsChecked}" Margin="10,10,0,0" VerticalAlignment="Center"
|
|
Checked="ItemCheckBox_OnCheckedChanged" Unchecked="ItemCheckBox_OnCheckedChanged" Padding="{StaticResource CheckboxToContentPadding}">
|
|
<TextBlock Text="{Binding Item}" FontSize="13">
|
|
<TextBlock.Style>
|
|
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
|
|
<Setter Property="FontWeight" Value="Normal"/>
|
|
<Setter Property="LayoutTransform">
|
|
<Setter.Value>
|
|
<!-- Scale up on the whole checkbox, scale down on the text so that it's not aliased -->
|
|
<!-- Done this way rather than overriding the template because keeping the presentation and style was too much hassle -->
|
|
<ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
|
|
</Setter.Value>
|
|
</Setter>
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Path=IsChecked, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}}" Value="True">
|
|
<Setter Property="FontWeight" Value="ExtraBold"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
</TextBlock>
|
|
<CheckBox.Style>
|
|
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource {x:Type CheckBox}}">
|
|
<Setter Property="FontWeight" Value="Normal"/>
|
|
<Setter Property="LayoutTransform">
|
|
<Setter.Value>
|
|
<ScaleTransform ScaleX="1.25" ScaleY="1.25"/>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</CheckBox.Style>
|
|
</CheckBox>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
<ItemsControl.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<WrapPanel IsItemsHost="True" Orientation="Vertical" MaxHeight="{Binding MaxListHeight}"/>
|
|
</ItemsPanelTemplate>
|
|
</ItemsControl.ItemsPanel>
|
|
</ItemsControl>
|
|
</StackPanel>
|
|
</UserControl>
|