Benutzer:MovGP0/WPF/Triggers
aus Wikipedia, der freien Enzyklopädie
< Benutzer:MovGP0 | WPF
Dies ist die aktuelle Version dieser Seite, zuletzt bearbeitet am 28. Dezember 2015 um 15:07 Uhr durch imported>MovGP0(77247).
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Triggers
PropertyTrigger
<ResourceDictionary (...)>
<Style TargetType="{x:Type local:MyControl}">
<Setter Property="Background" Value="White">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyControl}">
<Grid Background="{TemplateBinding Background}">
<!-- ... -->
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
MultiTrigger
<ResourceDictionary (...)>
<Style TargetType="{x:Type local:MyControl}">
<Setter Property="Background" Value="White">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyControl}">
<Grid Background="{TemplateBinding Background}">
<TextBox x:Name="textBox"
Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="Text" Value="Hello" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="Green" />
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="BorderThickness" Value="5" TargetName="textBox" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
EventTrigger
<ResourceDictionary (...)>
<Style TargetType="{x:Type local:MyControl}">
<Setter Property="Background" Value="White">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyControl}">
<Grid Background="{TemplateBinding Background}">
<TextBox x:Name="textBox"
Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
To="Green" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
To="White" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
DataTrigger
MultiDataTrigger |