0

It seems it is very common to pass a static value to the ConverterParameter like the xaml example below.

Is there way to pass the parent control Tag property to it?

<StackPanel Margin="{StaticResource XSmallTopMargin}" Tag="abc">
    <RadioButton GroupName="AppTheme" dt:DesignTime.Content="Light"
        Checked="ThemeChanged_CheckedAsync" 
        IsChecked="{x:Bind ElementTheme, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Light, Mode=OneWay}">
    </RadioButton>
</StackPanel>
Elaine Bel
  • 103
  • 3

1 Answers1

0

You can't. At least not that I'm aware. It would require you to bind it and there's no way to bind anything to ConverterParameter. x:Static and StaticResource are fine ways to pass something to ConverterParameter. But Binding won't work

However what you could do is also make your converter also support IMultiValueConverter and then pass the parent tag in a MultiBinding.

I'm probably about to butcher your binding but it's roughly like this.

<RadioButton GroupName="AppTheme" dt:DesignTime.Content="Light"
    Checked="ThemeChanged_CheckedAsync" >
    <RadioButton.IsChecked>
        <MultiBinding  Converter="{StaticResource EnumToBooleanConverter}">
            <Binding Source="{x:Bind ElementTheme}"/>
            <Binding RelativeSource="{RelativeSource Self}" Path="Tag"/>
        </MultiBinding>           
    </RadioButton.IsChecked>
</RadioButton>
Joe
  • 5,394
  • 3
  • 23
  • 54