Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadioButton ContentStringFormat not working

I have been struggling to get this code below to work. The binding works but the ContentStringFormat in the first or StringFormat in the second one doesn't seem to work.

<RadioButton Content="{Binding ClientCode}" ContentStringFormat="{}{0} copy"
             IsChecked="{Binding Path= FilterType,
                 Converter={StaticResource EBConverter}, 
                 ConverterParameter={x:Static wordMerge:FilterType.ClientCopy}}" 
             Width="90"/>

The above code just returns the binding value say "ABC" but I am expecting "ABC copy"

 <RadioButton IsChecked="{Binding Path= FilterType,
                 Converter={StaticResource EBConverter},
                 ConverterParameter={x:Static wordMerge:FilterType.ClientCopy}}" 
              Width="90">
    <RadioButton.Content>
        <TextBlock Text="{Binding ClientCode, StringFormat={}{0} copy}"/>
     </RadioButton.Content>
 </RadioButton>

The above code not returning any values for binding.

Updated The string copy is not displayed during design time or at runtime in both cases.

like image 338
Kiru Avatar asked Jul 31 '26 18:07

Kiru


1 Answers

Try this

StringFormat='{}copy {0}'}"

tested

<TextBlock Text="{Binding Path=Str, Mode=OneWay, StringFormat='{}{0} copy'}"/>   

@Kiru it works for me

<RadioButton Content="{Binding Path=Str, Mode=OneWay}"  ContentStringFormat='{}{0} copy'/>
<RadioButton>
    <TextBlock Text="{Binding Path=Str, Mode=OneWay, StringFormat='{}{0} copy'}"/>
</RadioButton>
like image 56
paparazzo Avatar answered Aug 03 '26 07:08

paparazzo