forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormsFlyout.xaml.cs
54 lines (43 loc) · 1.37 KB
/
FormsFlyout.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.UWP
{
public sealed partial class FormsFlyout : UserControl
{
ActionSheetArguments options;
public event EventHandler OptionSelected;
public FormsFlyout(ActionSheetArguments sheetOptions)
{
this.InitializeComponent();
options = sheetOptions;
TitleBlock.Text = options.Title ?? string.Empty;
OptionsList.ItemsSource = options.Buttons.ToList();
if (options.Cancel != null)
{
RightBtn.Content = options.Cancel;
if (options.Destruction != null)
LeftBtn.Content = options.Destruction;
}
else if (options.Destruction != null)
RightBtn.Content = options.Destruction;
LeftBtn.Visibility = LeftBtn.Content == null ? Visibility.Collapsed : Visibility.Visible;
RightBtn.Visibility = RightBtn.Content == null ? Visibility.Collapsed : Visibility.Visible;
}
void ListItemSelected (object sender, ItemClickEventArgs e)
{
var selection = (string)e.ClickedItem;
options.SetResult(selection);
OptionSelected?.Invoke(this, null);
}
void ActionButtonClicked(object sender, RoutedEventArgs e)
{
var button = (Windows.UI.Xaml.Controls.Button)sender;
var selection = (string)button.Content;
options.SetResult(selection);
OptionSelected?.Invoke(this, null);
}
}
}