[.CS]
public partial class MainPage : ContentPage {
public SfComboBox comboBox;
AcceptPopupCommand acceptCommand;
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
popup.Show();
}
protected override void OnAppearing()
{
base.OnAppearing();
acceptCommand = new AcceptPopupCommand();
popup.PopupView.AcceptCommand = acceptCommand;
}
private void Warehouse_selection_drop_BindingContextChanged(object sender, EventArgs e)
{
comboBox = (sender as SfComboBox);
acceptCommand.ComboBox = comboBox;
}
}
…
public class AcceptPopupCommand : ICommand
{
public SfComboBox ComboBox { get; set; }
private List<int> SelectedWarehouses = new List<int>();
private List<int> SelectedChains = new List<int>();
private List<int> SelectedLocations = new List<int>();
public event EventHandler CanExecuteChanged;
public AcceptPopupCommand()
{
}
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
if (ComboBox.SelectedIndices != null)
{
foreach (var obj in ((List<int>)ComboBox.SelectedIndices))
{
SelectedWarehouses.Add(obj);
}
MessagingCenter.Send<List<int>>(SelectedWarehouses, "WarehouseSelectedStatement");
}
}
}
[XAML]
<ContentPage.Resources>
<DataTemplate x:Key="StatementFilterTemplate">
<StackLayout>
<StackLayout
x:Name="warehouse_override_selection"
Orientation="Vertical">
<Label/>
<combobox:SfComboBox
BindingContextChanged="Warehouse_selection_drop_BindingContextChanged"
x:Name="warehouse_selection_drop"
MultiSelectMode="Token"
Watermark="Select Warehouse"
DataSource="{Binding MobileCollection}"
DisplayMemberPath="Mobile">
<combobox:SfComboBox.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Mobile}"></Label>
</DataTemplate>
</combobox:SfComboBox.ItemTemplate>
</combobox:SfComboBox>
</StackLayout>
</StackLayout>
</DataTemplate>
</ContentPage.Resources>
|
[XAML]
<ContentPage.Content> <sfPopup:SfPopupLayout x:Name="popup" Closing="Popup_Closing">
<sfPopup:SfPopupLayout.PopupView>
<sfPopup:PopupView ContentTemplate="{StaticResource StatementFilterTemplate}">
sfPopup:PopupView>
sfPopup:SfPopupLayout.PopupView>
<sfPopup:SfPopupLayout.Content>
<Button Text="clickTo Show popup" Clicked="Button_Clicked">Button>
sfPopup:SfPopupLayout.Content>
sfPopup:SfPopupLayout>
ContentPage.Content>
[.CS] public partial class MainPage : ContentPage {
public SfComboBox comboBox;
List<int> selectedIndices = new List<int>();
…. private void Warehouse_selection_drop_BindingContextChanged(object sender, EventArgs e)
{
comboBox = (sender as SfComboBox);
if (selectedIndices != null)
comboBox.SelectedIndices = selectedIndices;
acceptCommand.ComboBox = comboBox;
}
….. private void Popup_Closing(object sender, Syncfusion.XForms.Core.CancelEventArgs e) {
selectedIndices.Clear(); foreach (var obj in ((List<int>)acceptCommand.ComboBox.SelectedIndices))
{
selectedIndices.Add(obj);
}
}
} } |