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=Content}"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With