I need to append a simple string to my commandparameter but doesnt work. Does StringFormat support this or am I doing anything wrong ?
<DataTemplate x:Key="ClickableHeaderTemplate">
<Button x:Name="btn" Content="{Binding}" Background="Transparent"
Command="{Binding DrilldownHeaderClicked}"
Tag="{Binding RelativeSource={RelativeSource Self}, Path=Conten开发者_JAVA技巧t}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag, StringFormat=somestring\{0\}}"> --- formatting doesnt work. tried without escape seq as well as in 'somesting{0}'.
</Button>
</DataTemplate>
The StringFormat property only works when the Type of the target property is string. In this case the target property is CommandParameter which is of type object. You'll need to create your own IValueConverter and use that as the Converter for your binding. There is an example IValueConverter similar to what you need in the SL docs for IValueConverter.
精彩评论