How to disable the date picker on "cancil" button click - wpf

I am learning wpf and xaml. And I want to disable the showing of date picker when cancil button is clicked. How can I achieve that in XAML using style. So when the red cancil button is clicked I want to hide or disable the date picker. Please help me.
Below is what I have till now
<UserControl x:Class="ucWorkOrderActivity"
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" Height="74" Width="570" Background="White" BorderBrush="Gray" BorderThickness="1" Loaded="UserControl_Loaded" MouseDoubleClick="UserControl_MouseDoubleClick">
<Grid>
<DockPanel Name="dkpControl" Margin="10,0,25,0" >
<StackPanel Name="stpMoveButtons" Orientation="Vertical" DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="5,0,0,0">
<Button Name="btnUp" Click="btnUp_Click" Height="25" Width="25" Content="▲" ToolTip="Move Action Up" IsEnabled="{Binding Path=IsUpEnabled}" Margin="0,5,5,10" />
<Button Name="btnDown" Click="btnDown_Click" Height="25" Width="25" Content="▼" ToolTip="Move Action Down" Margin="0,0,5,10" IsEnabled="{Binding Path=IsDownEnabled}" />
</StackPanel>
<DockPanel DockPanel.Dock="Top" Margin="0,0,5,0" >
<TextBlock Name="txbDesc" Text="{Binding Path=Description}" Width="150" TextTrimming="CharacterEllipsis" Margin="10,5,5,5" VerticalAlignment="Top" />
<DockPanel Margin="5,0" HorizontalAlignment="Right" DockPanel.Dock="Right" Width="358" >
<TextBlock Name="txbCostLabel" Text="Cost: " DockPanel.Dock="Left" VerticalAlignment="Top" Margin="46,5,0,5" />
<TextBlock Name="txbCost" Text="{Binding Path=AmountCharged}" TextAlignment="Right" DockPanel.Dock="Left" Width="50" Margin="5" VerticalAlignment="Top" />
<DatePicker Name="dtpCompleted" DockPanel.Dock="Right" Height="25" VerticalAlignment="Top" Margin="0,1,0,0" SelectedDate="{Binding Path=EndDate}" Width="90" />
<TextBlock Name="txbStatus" Text="{Binding Path=Status}" DockPanel.Dock="right" HorizontalAlignment="Left" Width="60" Margin="45,5,30,5" TextAlignment="Left" VerticalAlignment="Top" />
</DockPanel>
</DockPanel>
<DockPanel DockPanel.Dock="Bottom" Margin="0,0,5,0" >
<Image Name="imgLocationChange" Margin="25,0" DockPanel.Dock="Left" Height="24" Source="/SMS_Main;component/Resources/UnitMoveLoc_24.png" Visibility="Hidden" />
<TextBlock Name="txbCharge" Text="{Binding Path=ChargeWhen}" Margin="70,0,0,0" VerticalAlignment="Center" />
<Button Name="btnComplete" Height="26" Width="26" DockPanel.Dock="Right" HorizontalAlignment="Right" Click="btnComplete_Click" ToolTip="Complete Action" >
<Image Source="/SMS_Main;component/Resources/OK_24.png" Margin="2" />
</Button>
<Button Name="btnCancel" Height="26" Width="26" DockPanel.Dock="Right" HorizontalAlignment="Right" Click="btnCancel_Click" ToolTip="Remove Action">
<Image Source="/SMS_Main;component/Resources/Cancel_24.png" Margin="2" />
</Button>
<Button Name="btnRevert" Height="26" Width="26" DockPanel.Dock="Right" HorizontalAlignment="Right" Click="btnRevert_Click" IsEnabled="{Binding Path=CurrentlySaved}" ToolTip="Revert Change">
<Image Source="/SMS_Main;component/Resources/Undo_24.png" Margin="2" />
</Button>
<Button Name="btnEdit" Height="26" Width="26" DockPanel.Dock="Right" HorizontalAlignment="Right" Click="btnEdit_Click" ToolTip="Edit Action" >
<Image Margin="2" Source="/SMS_Main;component/Resources/Config_24.png" />
</Button>
<TextBlock Name="txbAssignedTo" Text="{Binding Path=AssignedUser}" VerticalAlignment="Center" DockPanel.Dock="Right" HorizontalAlignment="Left" Margin="95,0,10,0" />
</DockPanel>
</DockPanel>
</Grid>
</UserControl>
.

You can add an event trigger to the cancel button:
<Button Name="btnCancel" Height="26" Width="26" DockPanel.Dock="Right" HorizontalAlignment="Right" ToolTip="Remove Action" Content="Cancel">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="dtpCompleted">
<DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="False"/>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>

Related

Label foreground in toolbar

I have a toolbar in my WPF window as shown in bellow, please help me change labels foreground color dynamically in code behind.
Thanks...
<DockPanel Height="60" VerticalAlignment="Top">
<ToolBar Name="MyToolBar" DockPanel.Dock="Top" Height="60" VerticalAlignment="Top" FlowDirection="RightToLeft"
FontFamily="Calibri" FontSize="16" FontWeight="Bold" Background="#FFEEF5FD" Foreground="Black" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<Button Name="BtnSubmit" Style="{DynamicResource TStyle}" Click="BtnSubmit_Click" Tag="New" Height="52" Width="60"
IsDefault="True" Margin="0,0,0,1">
<StackPanel Margin="0" Height="54"
<Image Source="/Img/Save 04.png" Height="25" Margin="16,0"/>
<Label Content="Save" Margin="0,0,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button Name="BtnApply" Style="{DynamicResource TStyle}" Click="BtnApply_Click" Tag="New" Height="52"
IsDefault="True" Margin="0,1,0,2" Width="85">
<StackPanel Margin="0" Height="52" Width="82">
<Image Source="/Img/ApplyIcon.png" Height="25" Margin="29,0,26,0"/>
<Label Content="Edit" Margin="-15,0,-23,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</ToolBar>
</DockPanel>
To change the Foreground of all TextBlock elements you must define a Brush resource and assign it to all relevant TextBlock elements using {DynamicResource}:
MainWindow.xaml
<Window>
<Window.Resources>
<SolidColorBrush x:Key="ButtonLabelForegroundBrush" Color="Black" />
</Window.Resources>
<DockPanel>
<ToolBar>
<Button>
<TextBlock Foreground="{DynamicResource ButtonLabelForegroundBrush}" />
</Button>
</ToolBar>
</DockPanel>
</Window>
MainWindow.xaml.cs
private void ChangeTextBlockForeground()
{
var brush = FindResource("ButtonLabelForegroundBrush") as SolidColorBrush;
brush.Color = Colors.Red;
}

Adding Scrollbar to ItemsControl

I have a long list coming from my Business logic which I need to display on the UI. As the list is long, I tried adding Scrollviewer but I am unable to scroll.
please find the XAML code below
<Grid Margin="0,32,0,0">
<TextBlock Text="{Binding IDC_WiFi, Source={StaticResource Resources}}" FontFamily="Segoe UI" FontSize="20" Foreground="#4cb5ab" HorizontalAlignment="Left" />
<Button Command="{Binding HardwareWifiAccordionCommand}" BorderThickness="0" Width="16" HorizontalAlignment="Right" Height="16" >
<Button.Background>
<ImageBrush ImageSource="{Binding AccordionImageHardwareWifi}" />
</Button.Background>
</Button>
</Grid>
<TextBlock Text="Klein's, Anil's" FontFamily="Segoe UI" FontSize="15" Foreground="#8fa3ad"/>
<StackPanel Height="200" Visibility="{Binding IsAccordionHardwareWifi, Converter={StaticResource Bool2Visible}}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding WifiList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,32,0,0">
<Grid>
<Image Source="/Images/Assets/da_wifi1_16x16.png" Height="16" Width="16" HorizontalAlignment="Left" />
<TextBlock Margin="25,0,0,0" Text="{Binding NetworkName}" FontSize="15" Foreground="#FFFFFF" />
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Right" />
</Grid>
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Left" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
Put it into a ScrollViewer.
<ScrollViewer>
<StackPanel >
</StackPanel>
</ScrollViewer>
As #StepUp points out you can just wrap it with a ScrollViewer but I believe this breaks virtualization. That's outside the scope of this question of course but it's something to keep in mind. If performance is likely to become an issue then I'd suggest implementing this as shown in the answer to this question.
The scrollviewer needed a Height to be set
<Grid Margin="0,32,0,0">
<TextBlock Text="{Binding IDC_WiFi, Source={StaticResource Resources}}" FontFamily="Segoe UI" FontSize="20" Foreground="#4cb5ab" HorizontalAlignment="Left" />
<Button Command="{Binding HardwareWifiAccordionCommand}" BorderThickness="0" Width="16" HorizontalAlignment="Right" Height="16" >
<Button.Background>
<ImageBrush ImageSource="{Binding AccordionImageHardwareWifi}" />
</Button.Background>
</Button>
</Grid>
<TextBlock Text="Klein's, Anil's" FontFamily="Segoe UI" FontSize="15" Foreground="#8fa3ad"/>
<StackPanel Height="200" Visibility="{Binding IsAccordionHardwareWifi, Converter={StaticResource Bool2Visible}}">
<ScrollViewer VerticalScrollBarVisibility="Auto" Height="350">
<ItemsControl ItemsSource="{Binding WifiList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,32,0,0">
<Grid>
<Image Source="/Images/Assets/da_wifi1_16x16.png" Height="16" Width="16" HorizontalAlignment="Left" />
<TextBlock Margin="25,0,0,0" Text="{Binding NetworkName}" FontSize="15" Foreground="#FFFFFF" />
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Right" />
</Grid>
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Left" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>

Binding Label to ItemsControl

I am having trouble working out how to bind the content of a label to the default (ToString()) value of ItemsControl object.
The ItemsControl element is bound to
stepList.ItemsSource = steps;
The steps object is
private var steps = new ObservableCollection<Action>();
<ItemsControl Name="stepList" Margin="10,2,10,10">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="GhostWhite" BorderBrush="Gainsboro" BorderThickness="1" Margin="0,2,0,2" DockPanel.Dock="Top">
<DockPanel Margin="0,2,0,2">
<DockPanel Width="106" HorizontalAlignment="Right" DockPanel.Dock="Right">
<Button DockPanel.Dock="Right" Click="_deleteStep" Width="22" Margin="0,0,10,0">
<Image Source="resources\icons\delete-bin.png" />
</Button>
<Button DockPanel.Dock="Right" Click="_editStep" Width="22" Margin="0,0,2,0">
<Image Source="resources\icons\edit.png" />
</Button>
<Button DockPanel.Dock="Right" Click="_moveDown" Width="22" Margin="0,0,2,0">
<Image Source="resources\icons\down.png" />
</Button>
<Button DockPanel.Dock="Right" Click="_moveUp" Width="22" Margin="0,0,2,0">
<Image Source="resources\icons\up.png" />
</Button>
</DockPanel>
<DockPanel DockPanel.Dock="Left">
<Label HorizontalAlignment="Stretch" Margin="10,0,0,0" Content="{????}"/>
</DockPanel>
</DockPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Figured it out!
Content="{Binding BindsDirectlyToSource=True}

Have image size to the window, but not the window to the image

I've been working on how to do layouts and I've come across something that is bugging the heck out of me. Now, if I use the code below, the window takes up the entirety of my screen.
<Window x:Class="HDD_Drill_View.Windows.WndwMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="HDDC"
WindowStartupLocation="CenterScreen"
Name="wndwMain"
Closing="WindowClosing"
ResizeMode="NoResize"
WindowState="Normal"
SizeToContent="WidthAndHeight">
<Grid>
<DockPanel Width="Auto"
LastChildFill="False"
HorizontalAlignment="Left">
<DockPanel.Background>
<ImageBrush ImageSource="..\Resources\background.png"
Stretch="UniformToFill"
TileMode="None" />
</DockPanel.Background>
<StackPanel DockPanel.Dock="Top"
Height="Auto"
Width="Auto"
Orientation="Horizontal"
HorizontalAlignment="Center">
<Button HorizontalAlignment="Left"
Name="bttnGenerateReports"
VerticalAlignment="Top"
UseLayoutRounding="False"
Click="BttnGenerateReportsClick"
Margin="10">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"><Run Text="Generate" /><LineBreak /><Run Text=" Reports" /></TextBlock>
</Button>
<Button HorizontalAlignment="Left"
Name="bttnSurveyReport"
VerticalAlignment="Top"
UseLayoutRounding="False"
Click="BttnSurveyReportClick"
Margin="10">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"><Run Text="Survey" /><LineBreak /><Run Text="Report" /></TextBlock>
</Button>
<Button HorizontalAlignment="Left"
Name="bttnTimeChart"
VerticalAlignment="Top"
UseLayoutRounding="False"
Click="BttnTimeChartClick"
Margin="10">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"><Run Text=" Time" /><LineBreak /><Run Text=" Chart" /></TextBlock>
</Button>
<Button HorizontalAlignment="Left"
Name="bttnMaterialAcquisition"
VerticalAlignment="Top"
UseLayoutRounding="False"
Click="BttnMaterialAcquisitionClick"
Margin="10">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"><Run Text=" Material" /><LineBreak /><Run Text="Acquistion" /></TextBlock>
</Button>
</StackPanel>
<StackPanel DockPanel.Dock="Bottom"
Height="Auto"
Width="Auto"
Orientation="Horizontal">
<!--MaxWidth="800"
MaxHeight="80"-->
<StackPanel.Background>
<ImageBrush ImageSource="..\Resources\drildata2.jpg" />
</StackPanel.Background>
</StackPanel>
</DockPanel>
</Grid>
</Window>
Yet, if I uncomment the Max Height and Max Width in the last StackPanel, then it seems fine. Basically, I'm wanting my background image to NOT affect my window size. Is this possible? I'm trying to set the background of a StackPanel to an image.
Remove the SizeToContent="WidthAndHeight" from the Window.

Collapse/Expand Groupboxes

I have the following XAML, in which there are three group boxes stacked. In the header of those groupboxes are checkboxes.
What I'd like to achieve : when I check/uncheck a box, I'd like the corresponding groupbox to slowly expand/collapse, with a smooth animation.
I'm trying this in Blend 4 but am quite a newbie. Any help on how to achieve this ? In particular, can the animation be self-contained in the XAML ?
UPDATE : This seems to come close , but I don't quite get it
<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">
<StackPanel x:Name="LayoutRoot" HorizontalAlignment="Stretch">
<GroupBox Margin="8,0" BorderBrush="#FF88B1D8">
<GroupBox.Header>
<WrapPanel>
<CheckBox IsChecked="True" VerticalAlignment="Center" />
<Label Content="Volatility" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" />
</WrapPanel>
</GroupBox.Header>
<UniformGrid Columns="2">
<Label Content="Spots"></Label>
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Hist. references" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Tenors" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
</UniformGrid>
</GroupBox>
<GroupBox Margin="8,0" BorderBrush="#FF88B1D8">
<GroupBox.Header>
<WrapPanel>
<CheckBox IsChecked="True" VerticalAlignment="Center" />
<Label Content="Skew" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" />
</WrapPanel>
</GroupBox.Header>
<UniformGrid Columns="2">
<Label Content="Spot Intervals"></Label>
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Hist. references" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Tenors" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Compute 'Power'" />
<CheckBox IsChecked="False" VerticalAlignment="Center"/>
</UniformGrid>
</GroupBox>
<GroupBox Margin="8,0" BorderBrush="#FF88B1D8">
<GroupBox.Header>
<WrapPanel>
<CheckBox IsChecked="True" VerticalAlignment="Center" />
<Label Content="Term structure" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" FontFamily="/WpfControlLibrary1;component/Fonts/#Tahoma" />
</WrapPanel>
</GroupBox.Header>
<UniformGrid Columns="2">
<Label Content="Spots" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Tenors" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
</UniformGrid>
</GroupBox>
</StackPanel>
</UserControl>
Just edited the first group box in your simple code:
<GroupBox Margin="8,0" BorderBrush="#FF88B1D8" Height="150">
<GroupBox.Resources>
<Style TargetType="GroupBox">
<Style.Triggers>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" Duration="0:0:.2" To="30" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Checked">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" Duration="0:0:.2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</GroupBox.Resources>
<GroupBox.Header>
<WrapPanel>
<CheckBox IsChecked="True" VerticalAlignment="Center" />
<Label Content="Volatility" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" />
</WrapPanel>
</GroupBox.Header>
<UniformGrid Columns="2">
<Label Content="Spots"></Label>
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Hist. references" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Tenors" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
</UniformGrid>
</GroupBox>
If you want to have this on a single group box you could place the Style Element inside this code
<GroupBox.Resources>
<!--Style Inside HEre-->
</GroupBox.Resources>
to implement it on a single group box.
Another suggestion is created a Style inside the stack panel and add a key to it:
<StackPanel.Resources>
<Style TargetType="GroupBox" x:Key="groupBoxStyle">
<Style.Triggers>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" Duration="0:0:.2" To="30" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Checked">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Height" Duration="0:0:.2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
then attached it to the style of the groupbox:
<GroupBox Margin="8,0" Height="150" BorderBrush="Transparent" Style="{StaticResource groupBoxStyle}">
<GroupBox.Header>
<WrapPanel>
<CheckBox IsChecked="True" VerticalAlignment="Center" />
<Label Content="Volatility" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" />
</WrapPanel>
</GroupBox.Header>
<Border BorderBrush="Black" BorderThickness="2">
<UniformGrid Columns="2">
<Label Content="Spots"></Label>
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Hist. references" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Tenors" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
</UniformGrid>
</Border>
</GroupBox>
this approach will be more useful when you want to implement this on the future to multiple groupboxes
In Case you want to handle the checkbox and unchecked event you could use this code
<GroupBox Margin="8,0" Height="150" BorderBrush="Transparent" Style="{StaticResource groupBoxStyle}" CheckBox.Checked="CheckBox_Checked" CheckBox.Unchecked="CheckBox_Unchecked">
<GroupBox.Header>
<WrapPanel>
<CheckBox x:Name="chkHeader" IsChecked="True" VerticalAlignment="Center" />
<Label Content="Volatility" Background="#00000000" Foreground="#FF0033FF" FontWeight="Bold" />
</WrapPanel>
</GroupBox.Header>
<Border BorderBrush="Black" BorderThickness="2">
<UniformGrid Columns="2">
<Label Content="Spots"></Label>
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Hist. references" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
<Label Content="Tenors" />
<TextBox AcceptsReturn="False" AcceptsTab="True" AllowDrop="True" IsTabStop="True" />
</UniformGrid>
</Border>
</GroupBox>
and add this in the code behind:
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
if ((e.OriginalSource as CheckBox).Name != "chkHeader")
{
e.Handled = true;
}
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
if ((e.OriginalSource as CheckBox).Name != "chkHeader")
{
e.Handled = true;
}
}
You probably should use an Expander for this (that's what they are for) and animate that.
If you don't like the look re-template them, you can make them look like a group-box.

Resources