Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

someone has an idea how I can bind the tag property of the textblock ("tbHeader") in the ContentTemplate of a DataGridColumnHeader Style to the SortMemberPath property of the DataGridTextColumn!?

<Style TargetType="{x:Type DataGridColumnHeader}">
					<Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
									<TextBlock x:Name="tbHeader" Text="{Binding}" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, Path=????}" Margin="5"/>
                                    <Button x:Name="BtnFilter" Click="BtnFilter_Click">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Image Source="/Images/filter.png" Width="12" Height="12" Margin="0,5,0,0" />
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                </StackPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>


<DataGrid.Columns>
				<DataGridTextColumn Header="Id"					    Width="auto" Visibility="Hidden" 					Binding="{Binding Id}" SortMemberPath="Id"  />
				<DataGridTextColumn Header="Material No"		    Width="auto"										Binding="{Binding Material_No}" SortMemberPath="Material_No"/>
				<DataGridTextColumn Header="Serial"		    Width="auto"										Binding="{Binding Serialnumber}" SortMemberPath="Serialnumber"/>
			</DataGrid.Columns>


I would be very happy about a tip

greetings

What I have tried:

Several attempts regarding binding and relative source
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900