wpftoolkit icon indicating copy to clipboard operation
wpftoolkit copied to clipboard

ContentStringFormat not working for SplitButtons

Open johanneszellinger opened this issue 4 years ago • 1 comments

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>

johanneszellinger avatar Nov 07 '20 11:11 johanneszellinger

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.

XceedBoucherS avatar Nov 27 '20 13:11 XceedBoucherS