Witajcie! :)
Mam sobie UserControl w którym zmienia się flaga:
private bool accountExist;
public bool AccountExist
{
get
{
return accountExist;
}
private set
{
accountExist = value;
if (accountExist == true)
MessageBox.Show("true");
else
MessageBox.Show("false");
OnPropertyChanged("AccountExist");
}
}
Chcę zmienić tło Grida za pomocą tej flagi, niestety nie mogę dojść dlaczego w xamlu pokazuje tak, jakby wartość była zawsze false.
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=AccountExist}" Value="False">
<Setter Property="Background" Value="Blue"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=AccountExist}" Value="True">
<Setter Property="Background" Value="Black"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
Pokazuje mi się cały czas niebieskie tło.
Dodatkowe informacje:
- W konstruktorze:
InitializeComponent();
this.DataContext = this;
PersonExist = false;
AccountExist = false;
- Po zalogowaniu się na konto pokazuje mi się MessageBox z wartością True, czyli wartość flagi się zmienia, lecz trigger tego nie wyłapuje.
- PropertChanged
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
var handler = this.PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
Jak potrzeba więcej informacji piszcie czego potrzebujecie aby mi pomóc.