gpt4 book ai didi

windows - 导航页面时 xaml 中的 InvalidCastException

转载 作者:可可西里 更新时间:2023-11-01 11:48:46 26 4
gpt4 key购买 nike

这是MainPage的点击事件代码

void ItemView_ItemClick(object sender, ItemClickEventArgs e)
{
var item = ((EventItem)e.ClickedItem);
this.Frame.Navigate(typeof(EventPage), new Navigator() { Parent = "Dashboard", Event = item });
}

In image the code of next page

最佳答案

加载事件的sender参数是引发事件的控件(在本例中为当前页面);所以它的类型是页面的类型,而不是 Navigator

显然,您正在尝试访问传递给 Frame.Navigate 的参数。为此,您应该覆盖 OnNavigatedTo 方法:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
var param = (Navigator)e.Parameter;
...
}

关于windows - 导航页面时 xaml 中的 InvalidCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36328437/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com