Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Reposting my answer from <a href="http://connect.microsoft.com/VisualStudio/feedback/details/509801/" rel="noreferrer">ms connect</a>:</p> <p>You can usually work around this by not using SharedSizeGroup and instead binding all shared sizes to single property on one object (eg. your datacontext):</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:WpfApplication3" Height="350" Width="525" Title="MainWindow"&gt; &lt;Window.DataContext&gt; &lt;my:MainWindowData Width0="1*" Width1="1*" /&gt; &lt;/Window.DataContext&gt; &lt;Window.Resources&gt; &lt;DataTemplate x:Key="dt"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="{Binding Path=Width0, Mode=TwoWay}" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="{Binding Path=Width1, Mode=TwoWay}" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Button Grid.Column="0" Content="{Binding Width0}" /&gt; &lt;GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" /&gt; &lt;Button Grid.Column="2" Content="{Binding Width1}" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;StackPanel&gt; &lt;ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource dt}" /&gt; &lt;ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource dt}" /&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p>Where Width0 and Width1 are of matching type (GridLength). It works with any kind of sizing (fixed, star and auto) in any combination. </p> <p><strong>UPDATE</strong>:</p> <p>Alternatively and perhaps better, instead of binding to DataContext, you can do it purely in XAML. Just define a single master grid (not necessarily a parent but you need some way to reference it) with named columns then bind to them by name.</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="350" Width="525" Title="MainWindow"&gt; &lt;!-- shared sizing used only on fixed size columns therefore safe --&gt; &lt;!-- alternatively you can hardcode width of splitter column --&gt; &lt;Grid Name="masterGrid" Grid.IsSharedSizeScope="True"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="1*" Name="masterColumn0" /&gt; &lt;ColumnDefinition Width="Auto" SharedSizeGroup="masterColumn1" /&gt; &lt;ColumnDefinition Width="1*" Name="masterColumn2" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;StackPanel Grid.ColumnSpan="3"&gt; &lt;StackPanel.Resources&gt; &lt;DataTemplate x:Key="dt"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="{Binding Path=Width, Mode=TwoWay, ElementName=masterColumn0}" /&gt; &lt;ColumnDefinition Width="Auto" SharedSizeGroup="masterColumn1" /&gt; &lt;ColumnDefinition Width="{Binding Path=Width, Mode=TwoWay, ElementName=masterColumn2}" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Button Grid.Column="0" Content="{Binding Path=Width, Mode=TwoWay, ElementName=masterColumn0}" /&gt; &lt;Button Grid.Column="2" Content="{Binding Path=Width, Mode=TwoWay, ElementName=masterColumn2}" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/StackPanel.Resources&gt; &lt;ContentPresenter ContentTemplate="{StaticResource dt}" /&gt; &lt;ContentPresenter ContentTemplate="{StaticResource dt}" /&gt; &lt;/StackPanel&gt; &lt;GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" ShowsPreview="True" /&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>This has added benefit of using a single grid splitter shared by all grids.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload