Question

I was trying to use a DataTrigger on the IsActive property but it doesn't work.

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Style>
        <Style TargetType="{x:Type Window}">
            <Setter Property="Title" Value="Active" />
            <Style.Triggers>
                <Trigger Property="IsActive" Value="False">
                    <Setter Property="Title" Value="Not active" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Style>
    <Grid>

    </Grid>
</Window>

I ended using this sample code that I found over MSDN forums(that as reportedly working) for testing and it doesn't work. Is this a bug or something like an API change?

Was it helpful?

Solution

Remove Title="MainWindow" attribute as it overrides values set by style and trigger.

Related MSDN article: Dependency Property Value Precedence

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top