/// <summary> /// 显示对话框 /// </summary> /// <param name="p_dlg">对话框</param> /// <param name="p_winPlacement">windows模式的显示位置</param> /// <param name="p_phonePlacement">phone模式的显示位置</param> /// <param name="p_target">采用相对位置显示时的目标元素</param> /// <param name="p_hideTitleBar">否隐藏标题栏</param> /// <param name="p_isPinned">是否固定对话框</param> /// <returns></returns> public static Task ShowAtAsync( this Dlg p_dlg, DlgPlacement p_winPlacement, DlgPlacement p_phonePlacement, FrameworkElement p_target = null, bool p_hideTitleBar = false, bool p_isPinned = false) { if (p_dlg != null) { p_dlg.WinPlacement = p_winPlacement; p_dlg.PhonePlacement = p_phonePlacement; if (p_target != null) { p_dlg.PlacementTarget = p_target; } if (p_hideTitleBar) { p_dlg.HideTitleBar = true; } if (p_isPinned) { p_dlg.IsPinned = true; } return(p_dlg.ShowAsync()); } return(Task.CompletedTask); }
/// <summary> /// 显示确认对话框 /// </summary> /// <param name="p_content">消息内容</param> /// <param name="p_title">标题</param> /// <returns>true表确认</returns> public Task <bool> Confirm(string p_content, string p_title) { var dlg = new Dlg { Title = p_title, IsPinned = true }; if (Kit.IsPhoneUI) { dlg.PhonePlacement = DlgPlacement.CenterScreen; dlg.Width = SysVisual.ViewWidth - 40; } else { dlg.WinPlacement = DlgPlacement.CenterScreen; dlg.MinWidth = 300; dlg.MaxWidth = SysVisual.ViewWidth / 4; dlg.ShowVeil = true; } Grid grid = new Grid { Margin = new Thickness(10) }; grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1.0, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); TextBlock tb = new TextBlock { Text = p_content, TextWrapping = TextWrapping.Wrap }; grid.Children.Add(tb); StackPanel spBtn = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 20, 0, 0), HorizontalAlignment = HorizontalAlignment.Right }; var btn = new Button { Content = "确认", Margin = new Thickness(0, 0, 20, 0) }; btn.Click += (s, e) => dlg.Close(true); spBtn.Children.Add(btn); btn = new Button { Content = "取消" }; btn.Click += (s, e) => dlg.Close(false); spBtn.Children.Add(btn); Grid.SetRow(spBtn, 1); grid.Children.Add(spBtn); dlg.Content = grid; return(dlg.ShowAsync()); }
async void OnAdd(object sender, Mi e) { Dlg dlg = new Dlg(); if (!Kit.IsPhoneUI) { dlg.Width = 600; dlg.Height = 600; } FolderPage page = new FolderPage(_fileMgr); dlg.Content = page; await dlg.ShowAsync(); LoadData(); }