一、跳轉的觸發
分為左鍵觸發和右鍵觸發,左鍵觸發的事件以及其處理方法
GridView_RightTapped
var Info = (e.OriginalSource as FrameworkElement)?.DataContext as InfoMdoel;
右鍵觸發的事件以及其處理方法:
GridView_SelectionChanged
InfoMdoel ObjSen = new InfoMdoel();
foreach (var item in e.AddedItems)
{
ObjSen = (InfoMdoel)item;
}
二、新窗體方法:
1.使用提示框:
ContentDialog content_dialog = new ContentDialog()
{
Title = "裝置"+Info.Type+"詳情",
Content = "裝置狀态:"+Info.Statue,
PrimaryButtonText = "傳回",
SecondaryButtonText = "删除裝置",
FullSizeDesired = true,
};
ContentDialogResult Reslut = await content_dialog.ShowAsync();
if (Reslut == ContentDialogResult.Secondary)
{
//傳回第二個按鍵的處理
}
導航到另外一個界面:
var Reslut= Frame.Navigate(typeof(DetailPage), Info);
另外一個界面需要添加構造函數:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter.GetType().Equals(typeof(InfoMdoel)))
{
InfoMdoel ObjSen = (InfoMdoel)e.Parameter;
txtTitle.Text = ObjSen.Type;
txtStatue.Text = ObjSen.Statue;
}
}