w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I setup binding so that selected value of combobox in one control changes control template of a different control?
  <Grid>
        <local:PrintBox x:Name="PrintBox"
                       Template="{Binding
ElementName=PrintTemplateComboBox,Path=SelectedValue}"/>
  </Grid>

or you can use a converter to be certain what you return back

    <UserControl.Resources>
        <Local:YourTemplateConverter x:Key="yourTemplateConverter"/>
    </UserControl.Resources>
    <Grid>
Template="{Binding
ElementName=PrintTemplateComboBox,Path=SelectedValue,Converter={StaticResource
yourTemplateConverter}}"
</Grid

and this is the converter

class YourTemplateConverter : IValueConverter
{

    public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
    {
       //value is whwat YourTemplateConverter get from the other combobox
    }

    public object ConvertBack(object value, Type targetType, object
parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.