//匿名对象 private void Button1_OnClick(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof(PageNavigate2), new { id = 1, name = "LBI" }); } //利用反射获取 protected override void OnNavigatedTo(NavigationEventArgs e) { var parameter = e.Parameter; var type = e.Parameter?.GetType(); if (type == null) { return; } var id = type.GetProperty("id").GetValue(parameter); var name = type.GetProperty("name").GetValue(parameter); Debug.WriteLine($"id:{id} name:{name}"); }
时间: 2024-11-05 11:29:16