From 15bb5cf88fae4b9a36655ee7decda5e69370bb91 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 4 Jun 2018 19:02:01 +0100 Subject: [PATCH] fix bug introduced in dropdownitem the clears :selected psuedo class from any control that has IsFocusedProperty. --- src/Avalonia.Controls/DropDownItem.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/DropDownItem.cs b/src/Avalonia.Controls/DropDownItem.cs index 3fd80c4562..fb465e93ec 100644 --- a/src/Avalonia.Controls/DropDownItem.cs +++ b/src/Avalonia.Controls/DropDownItem.cs @@ -22,14 +22,13 @@ namespace Avalonia.Controls static DropDownItem() { FocusableProperty.OverrideDefaultValue(true); - IsFocusedProperty.Changed.Subscribe(x => - { - var sender = x.Sender as IControl; + } - if (sender != null) - { - ((IPseudoClasses)sender.Classes).Set(":selected", (bool)x.NewValue); - } + public DropDownItem() + { + this.GetObservable(DropDownItem.IsFocusedProperty).Subscribe(focused => + { + PseudoClasses.Set(":selected", focused); }); }