Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiplePickerField added SelectedItems Change Event #807

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/UraniumUI.Material/Controls/MultiplePickerField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Windows.Input;
using UraniumUI.Dialogs;

namespace UraniumUI.Material.Controls;
Expand All @@ -24,6 +25,8 @@ protected set

public override bool HasValue { get => IsBusy || SelectedItems?.Count > 0; }

public event EventHandler<object> SelectedValuesChanged;

protected IDialogService DialogService { get; }

protected FlexLayout chipsHolderLayout;
Expand Down Expand Up @@ -133,6 +136,8 @@ protected virtual void OnSelectedItemsSet(IList oldValue, IList newValue)
private void SelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
UpdateState();
SelectedValuesChangedCommand?.Execute(SelectedItems);
SelectedValuesChanged?.Invoke(sender, SelectedItems);
}

public IList ItemsSource { get => (IList)GetValue(ItemsSourceProperty); set => SetValue(ItemsSourceProperty, value); }
Expand All @@ -150,4 +155,11 @@ private void SelectedItemsChanged(object sender, NotifyCollectionChangedEventArg
typeof(IList),
typeof(MultiplePickerField),
propertyChanged: (bindable, oldValue, newValue) => (bindable as MultiplePickerField).OnSelectedItemsSet(oldValue as IList, newValue as IList));

public ICommand SelectedValuesChangedCommand { get => (ICommand)GetValue(SelectedValuesChangedCommandProperty); set => SetValue(SelectedValuesChangedCommandProperty, value); }

public static readonly BindableProperty SelectedValuesChangedCommandProperty = BindableProperty.Create(
nameof(SelectedValuesChangedCommand),
typeof(ICommand), typeof(MultiplePickerField),
defaultValue: null);
}
Loading