I have the following DataTemplate in resources that I would like to reuse in a GridView.
<Window.Resources>
<DataTemplate x:Key="NumericalDataTemplate" DataType="GridViewColumn.CellTemplate">
<StackPanel Orientation="Horizontal" Height="32">
<TextBlock Text="{Binding MyLength}" VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}" >
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding PropertyEditable}" Value="True">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
</DataTemplate>
</Window.Resources>
What is implemented as follows.
<GridViewColumn Header="MyLength" Width="80"
CellTemplate="{StaticResource NumericalDataTemplate}" />
I would like to change the TextBlock binding (currently Text={Binding MyLength}) so that it can use a custom binding for each GridViewColumn cell template (e.g. MyHeight, MyWeight, etc.).
The way I intended to do this is to change the TextBlock binding to just use {Binding}and have a GridViewColumn, set the binding. However, I'm not sure where and how to do this, since setting DisplayMemberValue to {Binding MyLength}(for example) just cancels the pattern.
I would like to do this completely in XAML.