Title window designation through && style triggers in XAML

I have a code like this

<Window x:Class="SolutionName.ClassName" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300" WindowStartupLocation="CenterOwner"> <Window.Style> <Style TargetType="Window"> <Style.Triggers> <DataTrigger Binding="{Binding Path=ItemKind}" Value="SomeKind"> <Setter Property="Title" Value="SomeTitle"/> </DataTrigger> <DataTrigger Binding="{Binding Path=ItemKind}" Value="SomeKind2"> <Setter Property="Title" Value="SomeTitle"/> </DataTrigger> 

I want to change the window title depending on the ItemKind property implemented in the viewmodel (set as a datacontext). The code above will not work, and I'm really confused because I cannot find any errors.

+4
source share
1 answer

The code seems great and works on my part. Have you INotifyPropertyChanged in your ViewModel class. You need to implement it in order to propagate any change in the property value in your ViewModel class to reflect it in the user interface.

A practical guide. Implement Property Change Notification

+2
source

Source: https://habr.com/ru/post/1397259/


All Articles