WPF more then one DataTrigger - wpf

Would you know why the XAML below is not working. It looks like I can not have more than one DataTrigger for an element. Those Storyboards within DataTrigger, as you can tell are being executed on a button click.
The end reason is that on a button click, one grid should slide up, and the other slide down, achieving sort of accordian animation. Thanks
<StackPanel Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,10,0,0">
<!--Add New Banner Grid-->
<!--<Grid DockPanel.Dock="Top" Background="#FFE0FFD2" Height="50">-->
<Grid x:Name="grdAddBunner">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Height" Value="50"></Setter>
<Setter Property="Background" Value="#FFE0FFD2"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=btnEditBunner, Path=IsPressed}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" From="150" To="0" Duration="0:0:0.5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=btnAddBunner, Path=IsPressed}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" From="0" To="150" Duration="0:0:0.5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Content="Add New Banner" HorizontalAlignment="Center" Foreground="DarkGreen" FontWeight="Bold"></Label>
<Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" Content="Fund"></Label>
<telerik:RadComboBox Grid.Row="1" Grid.Column="1" telerik:StyleManager.Theme="Windows8" Margin="3" ItemsSource="{Binding LstFund}"></telerik:RadComboBox>
<Label Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" Content="Banner"></Label>
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" telerik:StyleManager.Theme="Windows8" Margin="3" Text="{Binding AddBannerName}"></TextBox>
<Button Grid.Row="3" Grid.Column="1" Content="Save" Command="{Binding AddBannerCmd}" Height="25" Width="80" HorizontalAlignment="Left"></Button>
<Button Grid.Row="3" Grid.Column="2" Content="Calcel" Height="25" Width="80" HorizontalAlignment="Right"></Button>
</Grid>
</Grid>
<!--Edit Existing Banner Grid-->
<!--<Grid DockPanel.Dock="Top" Background="#FFFFF7D2" Height="50">-->
<Grid x:Name="grdEditBanner">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Height" Value="50"></Setter>
<Setter Property="Background" Value="#FFFFF7D2"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=btnAddBunner, Path=IsPressed}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" From="150" To="0" Duration="0:0:0.5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=btnEditBunner, Path=IsPressed}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" From="0" To="150" Duration="0:0:0.5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Content="Edit Existing Banner" HorizontalAlignment="Center" Foreground="#FF5B6400" FontWeight="Bold"></Label>
<Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" Content="Fund"></Label>
<telerik:RadComboBox Grid.Row="1" Grid.Column="1" telerik:StyleManager.Theme="Windows8" Margin="3" ItemsSource="{Binding LstFund}" SelectedItem="{Binding SelectedBannerFund}"></telerik:RadComboBox>
<Label Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" Content="Banner"></Label>
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" telerik:StyleManager.Theme="Windows8" Margin="3" Text="{Binding SelectedBannerName}"></TextBox>
<Button Grid.Row="3" Grid.Column="1" Content="Save" Command="{Binding UpdateBannerCmd}" Height="25" Width="80" HorizontalAlignment="Left"></Button>
<Button Grid.Row="3" Grid.Column="2" Content="Calcel" Height="25" Width="80" HorizontalAlignment="Right"></Button>
</Grid>
</Grid>
</StackPanel>

The "IsPressed" lets you know when the button is "active" this changes again when you release the button.
Have you tried moving this to a command binding on the button and set properties on your viewModel that those grids can use to set styles on themselves?

Related

WPF Expander on two dependent controls

I didn't quite understand how Expander works,
I am trying to expand the green Grid so that the yellow Grid (including the red one)
moves to the left according to the expansion of the green Grid.
Currently, the situation is that the green Grid expands so it hides the red part because it exceeds the second Grid.
<ControlTemplate x:Key="ExpanderKey" TargetType="Expander">
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.2" AccelerationRatio="1" To="150" Storyboard.TargetName="Container" Storyboard.TargetProperty="Width" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.2" AccelerationRatio="1" To="50" Storyboard.TargetName="Container" Storyboard.TargetProperty="Width" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.05*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Background="Yellow"/>
<Button Grid.Column="1" Background="Red"/>
</Grid>
<Expander Grid.Column="1" IsExpanded="{Binding ElementName=SearchButton, Path=IsChecked}" Template="{StaticResource ExpanderKey}" HorizontalAlignment="Right" Background="Green">
<ToggleButton Grid.Row="0" x:Name="SearchButton" VerticalAlignment="Top" Content="Exp" HorizontalAlignment="Left"/>
</Expander>
</Grid>
Your ControlTemplate is invalid. Also, the Grid with the buttons spans both columns.
This is an example of an Expander that pushes the buttons to the left when it expands its content:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.05*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Background="Yellow"/>
<Button Grid.Column="1" Background="Red"/>
</Grid>
<Expander Grid.Column="1" IsExpanded="{Binding ElementName=SearchButton, Path=IsChecked}" HorizontalAlignment="Right" Background="Green" ExpandDirection="Right">
<ToggleButton Grid.Row="0" x:Name="SearchButton" VerticalAlignment="Top" Content="Exp" HorizontalAlignment="Left"/>
</Expander>
</Grid>

Get the the source from ToggleButton contained into a style

I have multiple expanders using a style. Into the style is defined a toggle button, and when I click on It I need to detect which off the togglebutton have been clicked.
expander 1:
<Expander Style="{StaticResource PreviewExpanderNewGeneration}" VerticalAlignment="Top" Grid.ColumnSpan="2" Name="expander1" OverridesDefaultStyle="True" Header="Expander1Header" Margin="0,0,0,0">
<GroupBox Height="150" FontStyle="Normal" utilities:GroupNameUpperConverter.CharacterCasing="Upper" Name="ContainerforExpander1" Background="#717171" Margin="0,0,0,0" >
</GroupBox>
</Expander>
expander 2:
<Expander Style="{StaticResource PreviewExpanderNewGeneration}" VerticalAlignment="Top" Grid.ColumnSpan="2" Name="expander2" OverridesDefaultStyle="True" Header="Expander2Header" Margin="0,0,0,0">
<GroupBox Height="150" FontStyle="Normal" utilities:GroupNameUpperConverter.CharacterCasing="Upper" Name="ContainerforExpander2" Background="#717171" Margin="0,0,0,0" >
</GroupBox>
</Expander>
the style define contains a Togglebutton who change graphically when clicked on. But I want to know which of the togglebutton from the expanders have been clicked:
XAML
<Style TargetType="Expander" x:Key="PreviewExpanderNewGeneration" BasedOn="{StaticResource BaseControlStyle}" >
<!--x:Key="GroupBoxStyle"-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Expander">
<Grid>
<!--Grid Rows split the GroupBox into two areas -->
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<!--Header area-->
<Border Name="HeaderArea"
Grid.Row="0"
Background="Transparent"
VerticalAlignment="Center"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="2,2,0,0" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67"/>
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="95"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="3" >
<Label Foreground="White" Grid.Column="0" utilities:LabelUpperCase.CharacterCasing="Upper" Name="PreviewLabelExpander" FontSize="15" HorizontalAlignment="Left" Loaded="PreviewLabelExpander_Loaded" FontWeight="Normal" Content="{TemplateBinding Header}" ></Label>
<StackPanel VerticalAlignment="Center">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Style.Triggers>
<DataTrigger Binding="{Binding IsHelp}" Value="true">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsHelp}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
</StackPanel>
</StackPanel>
<ToggleButton
Grid.Row="0"
Grid.Column="3"
Margin="79,4,0,4"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Template="{StaticResource PreviewToggleButton}"
OverridesDefaultStyle="True"
Click="PreviewExpanderButton_Click"
IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
Width="20">
</ToggleButton>
</Grid>
</Border>
<!-- Main client area -->
<Border Name="ContentArea"
Grid.Row="1"
Height="100"
BorderBrush="Transparent"
BorderThickness="1,1,1,1"
CornerRadius="6,5,6,6" >
<ContentPresenter x:Name="ExpanderContent"
VerticalAlignment="Top"
Height="100"
Margin="0,0,0,0" >
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleY="0"></ScaleTransform>
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="ExpanderContent"
Storyboard.TargetProperty="(ContentPresenter.LayoutTransform).(ScaleTransform.ScaleY)"
To="1"
Duration="0:0:0.4"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="ExpanderContent"
Storyboard.TargetProperty="(ContentPresenter.LayoutTransform).(ScaleTransform.ScaleY)"
To="0"
Duration="0:0:0.4"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
and now the click event should detect the source but how?
private void PreviewExpanderButton_Click(object sender, RoutedEventArgs e)
{
//how to detect which of the toogle button have been clicked?
ToggleButton tmp = (ToggleButton) sender;
}
If you want to get a reference to the parent Expander of the ToggleButton that was clicked, you could use the following helper method:
private void PreviewExpanderButton_Click(object sender, RoutedEventArgs e)
{
ToggleButton tmp = (ToggleButton)sender;
Expander expander = FindParent<Expander>(tmp);
MessageBox.Show(expander?.Name ?? String.Empty);
}
private static T FindParent<T>(DependencyObject dependencyObject) where T : DependencyObject
{
var parent = VisualTreeHelper.GetParent(dependencyObject);
if (parent == null) return null;
var parentT = parent as T;
return parentT ?? FindParent<T>(parent);
}

Change Grid Panel Border color Using C# programatically- WPF

I have Grid Panel and I want to its border color to change when we click on button
<Grid Grid.Row="3" Name="LocationLayoutPanel" VerticalAlignment="Top"
Margin="0,51,0,0" Height="65" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="9*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions >
<Border BorderThickness="2,2,2,2" BorderBrush="Red" Grid.ColumnSpan="3"
Grid.RowSpan="2"/>
<Button Content="change border color" Grid.Row="1" Grid.Column="1"
Click="chnageBGCOLOR"></Button>
</Grid>
When I click on "change border color" button its grid border color should be changed!
Thank you!
XAML:
<Border BorderThickness="2,2,2,2" Grid.ColumnSpan="3"
Grid.RowSpan="2">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="Red"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Button, Path=IsPressed}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
To="GreenYellow"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
<Button Name="Button" Content="change boarder color" Grid.Row="1" Grid.Column="1"></Button>
Programically:
Add Name to Border and set as follows:
BorderName.BorderBrush = new SolidColorBrush(Colors.GreenYellow);

WPF Animate Insertion into an ItemsControl

Earlier I asked about a fade-in,scroll down animation for items control insertion ( Animate Insertions to ItemsControl ). I got the fade-in working but I'm still perplexed about the items control insertion animation. Below is somethings that "sort of" works.
<Grid>
<ScrollViewer>
<ItemsControl Name="TimelineItems"
ItemsSource="{Binding Timeline}"
Style="{StaticResource TimelineStyle}"
ItemContainerStyle="{StaticResource TweetItemStyle}">
<ItemsControl.RenderTransform>
<TransformGroup>
<TranslateTransform />
</TransformGroup>
</ItemsControl.RenderTransform>
<ItemsControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.SizeChanged">
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="TimelineItems"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)">
<EasingDoubleKeyFrame KeyTime="0"
Value="-50" />
<EasingDoubleKeyFrame KeyTime="0:0:0.5"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ItemsControl.Triggers>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="MyGrid"
Background="{Binding TweetType, Converter={StaticResource tweetTypeConverter}}"
VerticalAlignment="Top"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource TweetImageColumnStyle}" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Rectangle Grid.Column="0"
Style="{StaticResource TweetImageStyle}">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding ProfileImageUrl}" />
</Rectangle.Fill>
</Rectangle>
<StackPanel Grid.Column="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Style="{StaticResource TweetNameStyle}"
Text="{Binding Name}" />
<TextBlock Grid.Column="1"
Style="{StaticResource TweetTimeStyle}"
Text="{Binding TimeAgo}" />
</Grid>
<Controls:TextBlockMarkup Grid.Row="1"
Grid.Column="1"
Markup="{Binding MarkupText}"
Style="{StaticResource TweetStyle}" />
</StackPanel>
<Separator Grid.Row="2"
Grid.ColumnSpan="2"
Style="{StaticResource TweetSeparatorTop}" />
<Separator Grid.Row="3"
Grid.ColumnSpan="2"
Style="{StaticResource TweetSeparatorBottom}" />
</Grid>
<DataTemplate.Resources>
<Storyboard x:Key="ItemAnimation"
AutoReverse="False">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="MyGrid"
Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="0"
Value="0" />
<EasingDoubleKeyFrame KeyTime="0:0:0.8"
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</DataTemplate.Resources>
<DataTemplate.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource ItemAnimation}" />
</EventTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
I say "sort of" because the list is offset by a negative offset and then animated into position. The "animation to position" looks great, but the "jump" to a negative offset spoils the affect.
In CSS, I would simply animate the height of the inserted item but I haven't puzzled out how to do this in WPF.
Thoughts?
So, I don't know all details, but I think usual way (I'm noob, lol) are:
Add FluidMove behavior to your visual collection
Insert new object with lower width and height, e.g. 1x1
Animate it to actual size via storyboard or manually DoubleAnimation

Make a groupbox appear and disappear with fade in fade out animation

in the following example, I don't understand how I could make my "Live Updates" groupbox appear/disappear when the upper checkbox is checked/unchecked. I am looking for a fast fade in/fade out effect in XAML but I am a little lost..
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="WpfControlLibrary1.MainControl"
x:Name="MultiVol" MinHeight="520.12" MinWidth="213">
<Grid HorizontalAlignment="Stretch">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0.966"/>
<GradientStop Color="#FFD7D4FF"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel x:Name="LayoutRoot" HorizontalAlignment="Stretch" Grid.Row="0">
<GroupBox Margin="8,0" BorderBrush="#FF88B1D8" HorizontalAlignment="Stretch" Height="99">
<GroupBox.Header>
<WrapPanel>
<Label Content="General" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" />
</WrapPanel>
</GroupBox.Header>
<UniformGrid Columns="2">
<Label Content="RICs" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Preference" />
<UniformGrid VerticalAlignment="Center" Columns="2" Rows="1">
<RadioButton GroupName="preference" Content="Exotic" IsChecked="False" />
<RadioButton GroupName="preference" Content="Flow" IsChecked="True" />
</UniformGrid>
<Label Content="Live updates" />
<CheckBox IsChecked="True" VerticalAlignment="Center"/>
</UniformGrid>
</GroupBox>
</StackPanel>
<DockPanel Grid.Row="1" HorizontalAlignment="Stretch">
<GroupBox Margin="8,0" BorderBrush="#FF88B1D8" HorizontalAlignment="Stretch">
<GroupBox.Header>
<WrapPanel>
<Label Content="Live updates" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" />
</WrapPanel>
</GroupBox.Header>
<ListView MinHeight="100" Background="{x:Null}">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Header="RIC" />
<GridViewColumn Header="Last tick" />
</GridView>
</ListView.View>
</ListView>
</GroupBox>
</DockPanel>
</Grid>
</UserControl>
UPDATE : I get the fade in now, and I tried to add the fade out by adding a Trigger tag :
<DockPanel.Style>
<Style TargetType="{x:Type DockPanel}">
<Style.Triggers>
<Trigger Property="Visibility" Value="Visible">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="00:00:0.5" From="0.0" To="1.0" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
<Trigger Property="Visibility" Value="Hidden">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="00:00:0.5" From="1.0" To="0.0" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
</DockPanel.Style>
Two steps.
First Visibility:
Create a BooleanToVisibilityConverter in Resources
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</UserControl.Resources>
Give your CheckBox a name
<CheckBox x:Name="LiveUpdateCheckBox" IsChecked="True" VerticalAlignment="Center" />
Bind the DockPanel.Visibility property per ElementName with BooleanToVisibilityConverter
<DockPanel Grid.Row="1" HorizontalAlignment="Stretch"
Visibility="{Binding ElementName=LiveUpdateCheckBox, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}">
Second Animation:
Create a DockPanel.Style for your LiveUpdates DockPanel
<DockPanel.Style>
<Style TargetType="{x:Type DockPanel}">
<Style.Triggers>
<Trigger Property="Visibility" Value="Visible">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="00:00:01" From="0.0" To="1.0" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
</DockPanel.Style>

Resources