Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Had the same issue and found out that using x:Reference you cannot refer to any container of the object you are using it from. Nasty hack, but I'd imagine if you created some other control (<code>TextBlock</code>) and bound it's width to the <code>DataGrid</code> <code>ActualWidth</code> and THEN used x:Reference on that <code>TextBlock</code> it would avoid the cyclical reference</p> <pre><code>&lt;TextBlock x:Name="TextBlock1" Width="{Binding ElementName=myDataGrid, Path=ActualWidth}" /&gt; &lt;DataGrid AutoGenerateColumns="False" Background="White" ItemsSource="{Binding Items, Mode=OneWay}" HorizontalGridLinesBrush="Silver" VerticalGridLinesBrush="Silver" Margin="332,10,10,10" CanUserAddRows="False" CanUserDeleteRows="False" x:Name="myDataGrid" ColumnWidth="*"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Width="{Binding Path=ActualWidth, Converter={StaticResource ResourceKey=WidthValueConverter}, Source={x:Reference Name=TextBlock1}}" IsReadOnly="True" Header="Column1" Binding="{Binding Value1, Mode=OneWay}" /&gt; &lt;DataGridTextColumn Width="{Binding Path=ActualWidth, Converter={StaticResource ResourceKey=WidthValueConverter}, Source={x:Reference Name=TextBlock1}}" IsReadOnly="True" Header="Column2" Binding="{Binding Value2, Mode=OneWay}"/&gt; &lt;DataGridTextColumn Width="{Binding Path=ActualWidth, Converter={StaticResource ResourceKey=WidthValueConverter}, Source={x:Reference Name=TextBlock1}}" IsReadOnly="True" Header="Column3" Binding="{Binding Value3, Mode=OneWay}"/&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre>
 

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