Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to use RelativeSource to Bind DataGridTemplateColumn Width to DataGrid ActualWidth Property

$
0
0

Hello,

I have a DataGrid control, the ActualWidth of which I would like to bind to the one DataGridTemplateColumn's Width property like so.

<DataGrid.Columns><DataGridTemplateColumn Header="File Name" IsReadOnly="True" Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, Path=ActualWidth}"><DataGridTemplateColumn.CellTemplate><DataTemplate><WrapPanel><Image Source="{Binding FileName, Converter={StaticResource localImageSourceConverter}}" Margin="0,0,5,0" HorizontalAlignment="Left" Stretch="None"></Image><TextBlock Text="{Binding FileName}" HorizontalAlignment="Stretch" Margin="0,0,5,0"></TextBlock></WrapPanel></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn></DataGrid.Columns>

 

However, the RelativeSource binding markup extension has no effect.  Is this even possible?

Thank you,

Dan



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>