Skip to content

Commit

Permalink
Pass person as parameter
Browse files Browse the repository at this point in the history
Issue #14
  • Loading branch information
lprichar committed Apr 13, 2017
1 parent daa81d7 commit 0f618a2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion SirenOfShame.Uwp.Ui/Controls/Leaders.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public Leaders()
private void ListViewBase_OnItemClick(object sender, ItemClickEventArgs e)
{
var person = e.ClickedItem as PersonDto;
Navigate<ViewUser>();
Navigate<ViewUser>(person);
}
}
}
4 changes: 2 additions & 2 deletions SirenOfShame.Uwp.Ui/Controls/UserControlBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ private T FindParent<T>(FrameworkElement element) where T : FrameworkElement
return FindParent<T>(parent);
}

protected void Navigate<T>()
protected void Navigate<T>(object parameter = null)
{
var page = FindParent<Page>();
page.Frame.Navigate(typeof(T));
page.Frame.Navigate(typeof(T), parameter);
}
}
}
2 changes: 1 addition & 1 deletion SirenOfShame.Uwp.Ui/Views/ViewUser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="View User" />
<TextBlock x:Name="Title" Text="View User" />
</Grid>
</Page>
9 changes: 9 additions & 0 deletions SirenOfShame.Uwp.Ui/Views/ViewUser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using SirenOfShame.Uwp.Ui.Models;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

Expand All @@ -26,5 +27,13 @@ public ViewUser()
{
this.InitializeComponent();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var person = e.Parameter as PersonDto;
if (person == null) return;
Title.Text = person.DisplayName;
}
}
}

0 comments on commit 0f618a2

Please sign in to comment.