J'ai un DataGrid et un Expander comme ceci:Reliure StringFormat ne semble pas fonctionner correctement
<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>
La liaison est très bien, mais pour une raison quelconque la mise en forme de chaîne ne fonctionnera pas. Il affiche toujours que la valeur dataGrid1.SelectedItem.Name J'ai aussi essayé:
StringFormat=Details of \{0\}
qui ne fonctionne pas.
J'ai même essayé simplement de définir la propriété HeaderStringFormat de l'Expander sur "Details of {0}" mais cela ne le formate pas non plus.
j'ai pu obtenir cette solution de contournement pour travailler si:
<Expander>
<Expander.Header>
<TextBox Text="{Binding ElementName=dataGrid1, Path=SelectedItem.Name, StringFormat=Details of {0}}"></TextBox>
</Expander.Header>
</Expander>
que quelqu'un sait pourquoi StringFormat ne fonctionne pas pour la propriété d'en-tête?
Très bien, c'est informatif. Merci. En outre, j'utilise un TextBlock ... Je pense que je l'ai juste mal écrit quand j'ai fait le post. – Adam