mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-30 09:40:52 +02:00
Many new plays
This commit is contained in:
207
PropertyPresenter2/PropertyPresenter2.xaml
Normal file
207
PropertyPresenter2/PropertyPresenter2.xaml
Normal file
@ -0,0 +1,207 @@
|
||||
<ContentControl
|
||||
x:Class="LsBricks.Controls.PropertyPresenter2"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:LsBricks.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Name="LayoutRoot"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300"
|
||||
Focusable="False"
|
||||
mc:Ignorable="d">
|
||||
<Validation.ErrorTemplate>
|
||||
<ControlTemplate />
|
||||
</Validation.ErrorTemplate>
|
||||
<ContentControl.Resources>
|
||||
<DataTemplate x:Key="DefaultDataTemplate">
|
||||
<Grid>
|
||||
<controls:TextBoxEx
|
||||
x:Name="InputTextBox"
|
||||
Text="{Binding Value, ElementName=LayoutRoot}"
|
||||
Validation.ErrorTemplate="{DynamicResource ValidationErrorTemplate}"
|
||||
Validation.ValidationAdornerSiteFor="{Binding ElementName=LayoutRoot}">
|
||||
<TextBox.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type controls:TextBoxEx}">
|
||||
<Setter Property="IsReadOnly" Value="True" />
|
||||
<Setter Property="UpdateBindingOnEnter" Value="False" />
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding Command, ElementName=LayoutRoot}" Value="{x:Null}" />
|
||||
<Condition Binding="{Binding IsReadOnly, ElementName=LayoutRoot}" Value="False" />
|
||||
<Condition Binding="{Binding IsChecked, ElementName=LayoutRoot, TargetNullValue=True}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsReadOnly" Value="False" />
|
||||
<Setter Property="UpdateBindingOnEnter" Value="True" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</controls:TextBoxEx>
|
||||
<TextBlock
|
||||
Margin="6,0,0,0"
|
||||
Padding="2,2,2,2"
|
||||
VerticalAlignment="Center"
|
||||
IsHitTestVisible="False"
|
||||
Text="{Binding Watermark, ElementName=LayoutRoot}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Setter Property="Opacity" Value="0.6" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Text, ElementName=InputTextBox}" Value="">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsFocused, ElementName=InputTextBox}" Value="True">
|
||||
<Setter Property="Opacity" Value="0.3" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="BooleanDataTemplate">
|
||||
<CheckBox
|
||||
Margin="0,4"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding Value, ElementName=LayoutRoot}"
|
||||
Validation.ErrorTemplate="{DynamicResource ValidationErrorTemplate}"
|
||||
Validation.ValidationAdornerSiteFor="{Binding ElementName=LayoutRoot}">
|
||||
<CheckBox.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type CheckBox}}" TargetType="{x:Type CheckBox}">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding Command, ElementName=LayoutRoot}" Value="{x:Null}" />
|
||||
<Condition Binding="{Binding IsReadOnly, ElementName=LayoutRoot}" Value="False" />
|
||||
<Condition Binding="{Binding IsChecked, ElementName=LayoutRoot, TargetNullValue=True}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsEnabled" Value="True" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</CheckBox.Style>
|
||||
</CheckBox>
|
||||
</DataTemplate>
|
||||
<controls:EnumToKeyValueListConverter x:Key="EnumToKeyValuePairConverter" />
|
||||
<DataTemplate x:Key="EnumComboBoxDataTemplate">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Key"
|
||||
ItemsSource="{Binding Value, ElementName=LayoutRoot, Converter={StaticResource EnumToKeyValuePairConverter}}"
|
||||
SelectedValue="{Binding Value, ElementName=LayoutRoot}"
|
||||
SelectedValuePath="Value"
|
||||
Validation.ErrorTemplate="{DynamicResource ValidationErrorTemplate}"
|
||||
Validation.ValidationAdornerSiteFor="{Binding ElementName=LayoutRoot}">
|
||||
<ComboBox.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding Command, ElementName=LayoutRoot}" Value="{x:Null}" />
|
||||
<Condition Binding="{Binding IsReadOnly, ElementName=LayoutRoot}" Value="False" />
|
||||
<Condition Binding="{Binding IsChecked, ElementName=LayoutRoot, TargetNullValue=True}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsEnabled" Value="True" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ComboBox.Style>
|
||||
</ComboBox>
|
||||
</DataTemplate>
|
||||
<controls:PropertyDataTemplateSelector
|
||||
x:Key="DataTemplateSelector"
|
||||
BooleanDataTemplate="{StaticResource BooleanDataTemplate}"
|
||||
DefaultDataTemplate="{StaticResource DefaultDataTemplate}"
|
||||
EnumComboBoxDataTemplate="{StaticResource EnumComboBoxDataTemplate}" />
|
||||
</ContentControl.Resources>
|
||||
<Grid Margin="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding LabelWidth, ElementName=LayoutRoot, FallbackValue=150}" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding IsChecked, ElementName=LayoutRoot}">
|
||||
<CheckBox.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type CheckBox}}" TargetType="CheckBox">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsChecked, ElementName=LayoutRoot}" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsReadOnly, ElementName=LayoutRoot}" Value="True">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</CheckBox.Style>
|
||||
</CheckBox>
|
||||
<TextBlock
|
||||
x:Name="PartLabel"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Focusable="False"
|
||||
Text="{Binding Label, ElementName=LayoutRoot}" />
|
||||
<controls:MagicSymbolControl
|
||||
x:Name="PartSymbol"
|
||||
Grid.Column="2"
|
||||
Margin="5,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Symbol="{Binding Symbol, ElementName=LayoutRoot}" />
|
||||
</Grid>
|
||||
<DockPanel Grid.Column="1">
|
||||
<Button
|
||||
x:Name="PartButton"
|
||||
Command="{Binding Command, ElementName=LayoutRoot}"
|
||||
CommandParameter="{Binding CommandParameter, ElementName=LayoutRoot}"
|
||||
Content="{Binding CommandContent, ElementName=LayoutRoot}"
|
||||
DockPanel.Dock="{Binding ButtonAlignment, ElementName=LayoutRoot}">
|
||||
<Button.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ButtonAlignment, ElementName=LayoutRoot}" Value="Right">
|
||||
<Setter Property="Margin" Value="5,0,0,0" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding ButtonAlignment, ElementName=LayoutRoot}" Value="Bottom">
|
||||
<Setter Property="Margin" Value="0,5,0,0" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding ButtonAlignment, ElementName=LayoutRoot}" Value="Left">
|
||||
<Setter Property="Margin" Value="0,0,5,0" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding ButtonAlignment, ElementName=LayoutRoot}" Value="Top">
|
||||
<Setter Property="Margin" Value="0,0,0,5" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Command, ElementName=LayoutRoot}" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsReadOnly, ElementName=LayoutRoot}" Value="False" />
|
||||
<Condition Binding="{Binding IsChecked, ElementName=LayoutRoot, TargetNullValue=True}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="IsEnabled" Value="True" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<ContentPresenter
|
||||
x:Name="PartContent"
|
||||
Content="{Binding Value, ElementName=LayoutRoot}"
|
||||
ContentTemplateSelector="{StaticResource DataTemplateSelector}"
|
||||
Focusable="False" />
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</ContentControl>
|
Reference in New Issue
Block a user