Skip to content

Commit

Permalink
feat: ComboBox.OnDropDownOpened/Closed
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jul 1, 2021
1 parent 2edcbd1 commit 13c8716
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ public object Description
// Forced skipping of method Windows.UI.Xaml.Controls.ComboBox.Description.set
// Forced skipping of method Windows.UI.Xaml.Controls.ComboBox.TextSubmitted.add
// Forced skipping of method Windows.UI.Xaml.Controls.ComboBox.TextSubmitted.remove
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
protected virtual void OnDropDownClosed( object e)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.ComboBox", "void ComboBox.OnDropDownClosed(object e)");
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
protected virtual void OnDropDownOpened( object e)
{
Expand Down
18 changes: 16 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ private protected override void OnUnloaded()
Xaml.Window.Current.SizeChanged -= OnWindowSizeChanged;
}

protected virtual void OnDropDownClosed(object e)
{
DropDownClosed?.Invoke(this, null!);
}

protected virtual void OnDropDownOpened(object e)
{
DropDownOpened?.Invoke(this, null!);
}

private void OnWindowSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
IsDropDownOpen = false;
Expand Down Expand Up @@ -370,9 +380,10 @@ partial void OnIsDropDownOpenChangedPartial(bool oldIsDropDownOpen, bool newIsDr
_popup.IsOpen = newIsDropDownOpen;
}

var args = new RoutedEventArgs() { OriginalSource = this };
if (newIsDropDownOpen)
{
DropDownOpened?.Invoke(this, newIsDropDownOpen);
OnDropDownOpened(args);

RestoreSelectedItem();

Expand All @@ -383,8 +394,11 @@ partial void OnIsDropDownOpenChangedPartial(bool oldIsDropDownOpen, bool newIsDr
}
else
{
DropDownClosed?.Invoke(this, newIsDropDownOpen);
OnDropDownClosed(args);
UpdateContentPresenter();

// Focus moves to ComboBox after item is selected.
Focus(FocusState.Programmatic);
}

UpdateDropDownState();
Expand Down

0 comments on commit 13c8716

Please sign in to comment.