How do you use a converter on a trigger


You can’t.

You can however use a data trigger and set the binding RelativeSource to Self. Data Triggers allow binding and bindings lets you have converters. Yey

Example:

       <Button Content="I change colour depending on my width for some reason">
            <Button.Triggers>
                <DataTrigger
                    Binding="{Binding
                    Path=Width,
                    RelativeSource={RelativeSource Self},
                    Converter={StaticResource isLessThanConverter},
                    ConverterParameter=50}"
                    Value="True">
                    <Setter Property="Button.Background" Value="Red" />
                DataTrigger>
            Button.Triggers>
        Button>

No comments:

Post a Comment