Prevent content to scroll - wpf

Essentially I've a DataGrid with multiple headers, in wpf there is no control that implement this so I've implemented my own solution.
The control look like this:
[Header1 ][Header2][Header3][Header4 ]
[column 1][column2][Column3][Column4][Column5][Column6]
so as you can see under specific column I've a header that group x columns.
This is my implementation:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Width="{Binding Path=Width, ElementName=RankingsHalfTime}">
<!-- multiple headers -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=HalfColumn0, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn1, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn2, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn3, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn4, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn5, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn6, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn7, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn8, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn9, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn10, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn11, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn12, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn13, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn14, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn15, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn16, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn17, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn18, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=HalfColumn19, Path=ActualWidth}"/>
</Grid.ColumnDefinitions>
<!-- Multiple Headers-->
<Border Grid.Column="2" Grid.ColumnSpan="6" BorderThickness="1 1 1 1" Margin="-1 0 -1 0">
<Label TextBlock.FontWeight='Bold' Background="WhiteSmoke" Content="Header 1" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="8" Grid.ColumnSpan="6" BorderThickness="1 1 1 1" Margin="0 0 -2 0">
<Label TextBlock.FontWeight='Bold' Background="WhiteSmoke" HorizontalAlignment="Center">Header 2</Label>
</Border>
</Grid>
<DataGrid AutoGenerateColumns="False"
CanUserAddRows="false" Grid.Column="1" Grid.Row="1"
RowStyle="{StaticResource CustomRowStyle}"
ItemsSource="{Binding RankingController.RankingsHalfTime}"
IsReadOnly="True" x:Name="RankingsHalfTime" >
<DataGrid.Columns>
<DataGridTextColumn Header="0" x:Name="HalfColumn0" Binding="{Binding Position}"/>
<DataGridTextColumn Header="1" x:Name="HalfColumn1" Binding="{Binding Team}" Width="200" />
<DataGridTextColumn Header="2" x:Name="HalfColumn2" />
<DataGridTextColumn Header="3" x:Name="HalfColumn3" />
<DataGridTextColumn Header="4" x:Name="HalfColumn4" />
<DataGridTextColumn Header="5" x:Name="HalfColumn5" />
<DataGridTextColumn Header="6" x:Name="HalfColumn6" />
<DataGridTextColumn Header="7" x:Name="HalfColumn7" />
<DataGridTextColumn Header="8" x:Name="HalfColumn8"/>
<DataGridTextColumn Header="9" x:Name="HalfColumn9" />
<DataGridTextColumn Header="10" x:Name="HalfColumn10" />
<DataGridTextColumn Header="12" x:Name="HalfColumn11" />
<DataGridTextColumn Header="12" x:Name="HalfColumn12" />
<DataGridTextColumn Header="13" x:Name="HalfColumn13" />
</DataGrid.Columns>
</DataGrid>
</Grid>
The code working pretty well, the result that I want is achieved successfully, but there is a problem:
when the window is resized, the DataGrid display an horizontal scrollbar, this will bug the logic of multiple headers, infact, when the user move the horizontal scrollbar, the multiple header doesn't keep fixed to the original position, so the final result is this (when I move the scrollbar):
[Header1 ][Header2][Header3][Header4 ]
[column 1][column2][Column3][Column4][Column5][Column6]
[scrollbar ]
I'm looking for a way to prevent multiple header scrolling and keep them to stuck at the original position. You can try my code for a better practice explanation.

Related

Sharing column widths between multiple grids

I have the following XAML:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Header 1" />
<TextBlock Grid.Column="1" Text="Header 2" />
</Grid>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding SomeList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Text="{Binding Value1}" />
<TextBox Grid.Column="1" Text="{Binding Value2}" />
<Button Grid.Column="2" Content="Button" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
and I want to achieve something like that:
Header 1 |Header 2 | <-- this is the top grid
------------------------------------------------------
Value 1.1 |Value 1.2 |[Button] |
Value 2.1 |Value 2.2 |[Button] <-- | this is the scroll viewer
Value 3.1 |Value 3.2 |[Button] |
which looks similar to a data grid with the fixed header row. I can't use an actual DataGrid because in the real app "Header 1" and "Header 2" are actually not simple grid text headers but rather interactable elements with quite complex markup. The main question is how to achieve the width synchronization for all three columns? The last column should size itself to the widest button in that column while the first two columns should share the remaining space in 50/50 proportion. It feels like this can be achieved using the SharedSizeGroup property but I cannot figure out how exactly.
I think I figured out how to do it:
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Width="{Binding ActualWidth, ElementName=itemsControl}"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="ButtonColumn" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Header 1" />
<TextBlock Grid.Column="1" Text="Header 2" />
</Grid>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl Name="itemsControl" ItemsSource="{Binding SomeList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="ButtonColumn" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Text="{Binding Value1}" />
<TextBox Grid.Column="1" Text="{Binding Value2}" />
<Button Grid.Column="2" Content="Button" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
Grid.IsSharedSizeScope="True" and SharedSizeGroup="ButtonColumn" synchronize the last columns.
Width="*" splits the remaining space between first two columns in 50/50 proportion.
Width="{Binding ActualWidth, ElementName=itemsControl}" synchronizes the width of the top header grid with the width of the ItemsControl below which can change when the scroll bar is shown or hidden.
HorizontalAlignment="Left" pushes the header grid to the left to align it with the ItemsControl below.

DataGrid Column Sets with a header for each set

I wanted to create a WPF data grid which displays a certian number of column sets for each category as in the below image:
enter image description here
Can anyone help me how we can achieve this with wpf Datagrid?
You can put your DataGrid in a Grid panel and then bind its ColumnDefinitions widths to the column headers widths. Something like:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=datagrid, Path=RowHeaderWidth}" />
<ColumnDefinition Width="{Binding ElementName=ColumnD, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=ColumnE, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=ColumnF, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=ColumnG, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=ColumnH, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=ColumnI, Path=ActualWidth}" />
</Grid.ColumnDefinitions>
<DataGridColumnHeader Grid.Column="1" Grid.ColumnSpan="2" Content="A" HorizontalContentAlignment="Center" />
<DataGridColumnHeader Grid.Column="3" Grid.ColumnSpan="2" Content="B" HorizontalContentAlignment="Center" />
<DataGridColumnHeader Grid.Column="5" Grid.ColumnSpan="2" Content="C" HorizontalContentAlignment="Center" />
</Grid>
<DataGrid Name="datagrid" AutoGenerateColumns="False"
Grid.Row="1" RowHeaderWidth="0">
<DataGrid.Columns>
<DataGridTextColumn Header="D" Width="*" x:Name="ColumnD" />
<DataGridTextColumn Header="E" Width="*" x:Name="ColumnE" />
<DataGridTextColumn Header="F" Width="*" x:Name="ColumnF" />
<DataGridTextColumn Header="G" Width="*" x:Name="ColumnG" />
<DataGridTextColumn Header="H" Width="*" x:Name="ColumnH" />
<DataGridTextColumn Header="I" Width="*" x:Name="ColumnI" />
</DataGrid.Columns>
</DataGrid>
</Grid>
My XAML does not consider header's borders, but you can easily include them by using a converter which gets the ActualWidth and sum it to the border thickness.
I hope it can help you.

SharedSizeGroup on dataGrid

I have a DataGrid and a grid on my WPF application and I want their respected columns be the same size. I thought maybe I use SharedSizeGroup but it seems that DataGrid columns don’t have this property (Am I wrong?).
How can I do this?
Update1
I changed the xaml as follow:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" MaxHeight="20" MinHeight="20" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="{Binding ElementName=titleDataGridColumn, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=forenameDataGridColumn, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=surnameDataGridColumn, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=dobDataGridColumn, Path=ActualWidth}" />
</Grid.ColumnDefinitions>
<Button Content="Clear" HorizontalAlignment="Stretch" Name="searchClearButton" VerticalAlignment="Stretch" Grid.Column="0" Click="searchClearButton_Click" />
<TextBox HorizontalAlignment="Stretch" Name="forenameTextBox" VerticalAlignment="Stretch" Grid.Column="1" />
<TextBox HorizontalAlignment="Stretch" Name="surnameTextBox" VerticalAlignment="Stretch" Grid.Column="2" />
<TextBox HorizontalAlignment="Stretch" Name="dobTextBox" VerticalAlignment="Stretch" Grid.Column="3" />
</Grid>
<DataGrid Grid.Row="1" x:Name="DataDataGrid" HorizontalAlignment="Stretch" AutoGenerateColumns="False" VerticalAlignment="Stretch" ItemsSource="{Binding}" AlternationCount="1" IsReadOnly="True" SelectionMode="Single" >
<DataGrid.Columns>
<DataGridTextColumn x:Name="titleDataGridColumn" Binding="{Binding Path='Title'}" Header="Title" Width="35*" />
<DataGridTextColumn x:Name="forenameDataGridColumn" Binding="{Binding Path='Forename'}" Header="Forename" Width="65*" />
<DataGridTextColumn x:Name="surenameDataGridColumn" Binding="{Binding Path='Surname'}" Header="Surname" Width="65*"/>
<DataGridTextColumn x:Name="dobDataGridColumn" Binding="{Binding DOB,StringFormat={}\{0:dd/MM/yyyy\}}" Header="DOB" Width="70*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
But now the surname column in grid is bigger than its corresponding column in datagrid and the button is a bit to left ( could be fixed by setting margin on grid column) but I cannot understand why surname columns are not same size?
Update 2
This is working (Problem was the surenameDataGridColumn was not correct (spelling))
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" MaxHeight="20" MinHeight="20" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="6px"/>
<ColumnDefinition Width="{Binding ElementName=titleDataGridColumn, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=forenameDataGridColumn, Path=ActualWidth}"/>
<ColumnDefinition Width="{Binding ElementName=surnameDataGridColumn, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=dobDataGridColumn, Path=ActualWidth}" />
</Grid.ColumnDefinitions>
<Button Content="Clear" HorizontalAlignment="Stretch" Name="searchClearButton" VerticalAlignment="Stretch" Grid.Column="1" Click="searchClearButton_Click" />
<TextBox HorizontalAlignment="Stretch" Name="forenameTextBox" VerticalAlignment="Stretch" Grid.Column="2" />
<TextBox HorizontalAlignment="Stretch" Name="surnameTextBox" VerticalAlignment="Stretch" Grid.Column="3" />
<TextBox HorizontalAlignment="Stretch" Name="dobTextBox" VerticalAlignment="Stretch" Grid.Column="4" />
</Grid>
<DataGrid Grid.Row="1" x:Name="DataGrid" HorizontalAlignment="Stretch" AutoGenerateColumns="False" VerticalAlignment="Stretch" ItemsSource="{Binding}" AlternationCount="1" IsReadOnly="True" >
<DataGrid.Columns>
<DataGridTextColumn x:Name="titleDataGridColumn" Binding="{Binding Path='Title'}" Header="Title" Width="35*" />
<DataGridTextColumn x:Name="forenameDataGridColumn" Binding="{Binding Path='Forename'}" Header="Forename" Width="65*" />
<DataGridTextColumn x:Name="surnameDataGridColumn" Binding="{Binding Path='Surname'}" Header="Surname" Width="65*"/>
<DataGridTextColumn x:Name="dobDataGridColumn" Binding="{Binding DOB,StringFormat={}\{0:dd/MM/yyyy\}}" Header="DOB" Width="70*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
By adding a new column, I aligned the left of button with the left of Title column in DataGrid.
Use binding to bind the Grid column widths to the size of the columns in your DataGrid. For example:
<dg:DataGridTextColumn x:Name="FirstColumn" Header="Text"/>
<ColumnDefinition Width="{Binding ElementName=FirstColumn, Path=ActualWidth}"/>

Horizontal Scroll Bar Always Appearing in WPF DataGrid

I am facing an issue. In my view I have a DataGrid whose Horizontal Scroll Bar's Visibility is set to Auto. Problem I am facing is that the scroll bar is appearing all the time even if there is enough space for DataGrid to expand and completely display itself. I have tried almost everything but couldn't figure out whats is wrong.
I have uploaded a sample application to demonstrate the problem here. Hoping anyone will point out mistake I am making.
I did following changes/workarounds to solve the issue. It might not be the perfect solution but works for me.
I added two more columns in the Grid, one in the start and one at the end.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=m_DataGrid, Path=RowHeaderWidth}" />
<ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=col2, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=col3, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=col4, Path=ActualWidth}" />
<ColumnDefinition x:Name="specialCol" />
</Grid.ColumnDefinitions>
Then I increased the ColumnSpan of DataGrid
...Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="6" ....
Then I added this line in Constrcutor of Window
specialCol.Width = new GridLength (2);
and changed UpdateGrid method to this
void UpdateGrid()
{
ScrollViewer scrollview = FindVisualChild<ScrollViewer>(m_DataGrid);
Visibility verticalVisibility = scrollview.ComputedVerticalScrollBarVisibility;
if (verticalVisibility == System.Windows.Visibility.Visible)
{
specialCol.Width = new GridLength(20);
m_Border.Width = m_DataGrid.ActualWidth - m_DataGrid.RowHeaderWidth - 17;
}
else
{
specialCol.Width = new GridLength(2);
m_Border.Width = m_DataGrid.ActualWidth - m_DataGrid.RowHeaderWidth;
}
}
I don't see any HorizontalScrollBar now until it is required
You need to remove the MinWidth you set for all the data grid columns, you could also set the data grid columns Width="*" to fill-in all the space available the them. see the code below
Ok, I found it, please remove the HorizontalAlignment from both m_MainGrid and m_DataGrid, moreover, remove all the ColumnDefinitions in m_MainGrid. I tried it on your solution and it worked.
<Window x:Class="Data_Grid_Issue.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid Margin="50" >
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border x:Name="m_Border" CornerRadius="5,5,0,0" BorderBrush="Black" Margin="20,0,0,0"
BorderThickness="1,1,1,0" HorizontalAlignment="Left" Background="LightBlue"
Width="{Binding ElementName=m_DataGrid, Path=ActualWidth}">
<Label Content="Hello" HorizontalAlignment="Center"/>
</Border>
<Grid x:Name="m_MainGrid" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=col2, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=col3, Path=ActualWidth}" />
<ColumnDefinition Width="{Binding ElementName=col4, Path=ActualWidth}" />
</Grid.ColumnDefinitions>-->
<DataGrid ScrollViewer.ScrollChanged="m_DataGrid_ScrollChanged" Width="Auto" x:Name="m_DataGrid" ItemsSource="{Binding Path= Testing}"
AutoGenerateColumns="False" Margin="0,0,0,0" EnableRowVirtualization="True"
RowHeaderWidth="20" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" Binding="{Binding Path=a}" MinWidth="200"
x:Name="col1" Header="Col1"></DataGridTextColumn>
<DataGridTextColumn Width="Auto" Binding="{Binding Path=b}" MinWidth="200"
x:Name="col2" Header="Col2"></DataGridTextColumn>
<DataGridTextColumn Width="Auto" Binding="{Binding Path=c}" MinWidth="200"
x:Name="col3" Header="Col3"></DataGridTextColumn>
<DataGridTextColumn Width="Auto" Binding="{Binding Path=d}" MinWidth="200"
x:Name="col4" Header="Col4"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>
</Grid>

Gridsplitter ignores minwidth of columns

I want to have a simple 3 column grid with resizeable columns and a MinWidth of 80.
The code looks like this:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" MinWidth="80"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" MinWidth="80"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="120" MinWidth="80"/>
</Grid.ColumnDefinitions>
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Center" />
<GridSplitter Grid.Column="3" Width="5" HorizontalAlignment="Center" />
</Grid>
But it doesn't work in the way I want and expected. When the splitters are pushed to the left, all works fine. When the second splitter is pushed to the right all works fine. But if the first splitter is pushed to the right, it pushes the 3rd column and the second splitter out of the grid(or makes their width=0).
I used seperate columns for the gridsplitters, like it was done in the msdn example:
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
...
<GridSplitter Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Background="Black"
ShowsPreview="True"
Width="5"
/>
I also set the alignment to center as i read somewhere right alignment could be a problem
and tried different ResizeBehaviors.
Does anyone know, how to fix this issue, so that at all time the 3 columns are visible with at least 80px width?
Thanks for any help
Try this instead for three columns that have minwidth set to 80. Use * instead of specifying exact width when using gridsplitters.
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="80" />
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*" MinWidth="80"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*" MinWidth="80"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=ActualWidth, RelativeSource={RelativeSource Self}}" />
<GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Red" />
<TextBlock Grid.Column="2" Text="{Binding Path=ActualWidth, RelativeSource={RelativeSource Self}}" />
<GridSplitter Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Red" />
<TextBlock Grid.Column="4" Text="{Binding Path=ActualWidth, RelativeSource={RelativeSource Self}}" />
</Grid>
</ScrollViewer>
Not able to post this as comments; So putting this in the Answer list.
If I put a Grid with GridSplitter as the content on the right side of the main Grid with GridSplitter, I'm able to push the right most pane out of bounds of the window. Any idea?
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="80" />
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*" MinWidth="80"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=ActualWidth, RelativeSource={RelativeSource Self}}" />
<GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Red" />
<Grid Grid.Column="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="80" />
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*" MinWidth="80"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=ActualWidth, RelativeSource={RelativeSource Self}}" />
<GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Red" />
<TextBlock Grid.Column="2" Text="{Binding Path=ActualWidth, RelativeSource={RelativeSource Self}}" />
</Grid>
</Grid>

Resources