3

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>

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.