I have a DataGrid and Expander like this:
<StackPanel> <my:DataGrid Name="dataGrid1" AutoGenerateColumns="False" ItemsSource="{Binding}">...</my:DataGrid> <Expander Header="{Binding ElementName=dataGrid1, Path=SelectedItem.Name, StringFormat=Details of {0}}">...</Expander> </StackPanel>
The binding is fine, but for some reason, line formatting will not work. It always only displays the value dataGrid1.SelectedItem.Name I also tried:
StringFormat=Details of \{0\}
which does not work.
I even tried just setting the HeaderStringFormat Expander property to "Details from {0}", but that also does not format it.
I managed to get this workaround to work:
<Expander> <Expander.Header> <TextBox Text="{Binding ElementName=dataGrid1, Path=SelectedItem.Name, StringFormat=Details of {0}}"></TextBox> </Expander.Header> </Expander>
Does anyone know why StringFormat is not working for the Header property?
wpf binding
Adam
source share