I have a DataGrid and an Expander like so:
<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 the string formatting will not work. It always displays only the value dataGrid1.SelectedItem.Name I have also tried:
StringFormat=Details of \{0\} which doesn't work.
I even tried just setting the HeaderStringFormat property of the Expander to "Details of {0}" but that doesn't format it either.
I was able to get this workaround to work though:
<Expander> <Expander.Header> <TextBox Text="{Binding ElementName=dataGrid1, Path=SelectedItem.Name, StringFormat=Details of {0}}"></TextBox> </Expander.Header> </Expander> Does anyone know why StringFormat isn't working for the Header property?