wpftoolkit
wpftoolkit copied to clipboard
ContentStringFormat not working for SplitButtons
I'm using a Splitbutton to add 'Configurations' based on the dropdown selection of the user in my software. I would like to display the name of the current configuration as the content of the splitbutton in the following manner: "Add CONFIGURATIONNAME".
Normally, this can be done in the following manner:
<xctk:SplitButton Name="AddConfigurationSplitButton" Grid.Row="2" Grid.Column="0" Command="{Binding AddConfigurationSplitButtonClick}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CommandParameter="{Binding AddConfigurationSplitButtonContent}" IsOpen="{Binding AddConfigurationSplitButtonIsOpen, Mode=TwoWay}" Margin="10, 0, 5, 0" Content="{Binding AddConfigurationSplitButtonContent}" ContentStringFormat="Add {0}">
<!-- dropdown stuff -->
</xctk:SplitButton >
However currently this doesn't work and the ContentStringFormat
seems to be ignored. Therefore, at the moment, I'm using the following workaround:
<xctk:SplitButton Name="AddConfigurationSplitButton" Grid.Row="2" Grid.Column="0" Command="{Binding AddConfigurationSplitButtonClick}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CommandParameter="{Binding AddConfigurationSplitButtonContent}" IsOpen="{Binding AddConfigurationSplitButtonIsOpen, Mode=TwoWay}" Margin="10, 0, 5, 0">
<xctk:SplitButton.ContentTemplate>
<DataTemplate>
<Label Content="{Binding ElementName=AddConfigurationSplitButton, Path=DataContext.AddConfigurationSplitButtonContent}" ContentStringFormat="Add {0}" Margin="0" Padding="2"/>
</DataTemplate>
</xctk:SplitButton.ContentTemplate>
<!-- dropdown stuff -->
</xctk:SplitButton>
Hi, Thank you for pointing this out. It will be fixed in the next release: v4.1. Other controls have been reviewed in order to use the ContentStringFormat property like DropDownButton and MultiLineTextEditor.