I made a simple sample to demonstrate you how you can pass parameteres from one page to other. I will not use MVVM architecture because it will be a simple demonstration.
Here is my MainPage:
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:App1"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="mainWindow"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView
Name="lvDummyData"
IsItemClickEnabled="True"
ItemClick="lvDummyData_ItemClick"
ItemsSource="{Binding ElementName=mainWindow, Path=DummyData}">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>
As you can see there is nothing special here. Only a listview with click enabled.
Here is how code behind looks like:
public ObservableCollection<string> DummyData { get; set; }
public MainPage()
{
List<string> dummyData = new List<string>();
dummyData.Add("test item 1");
dummyData.Add("test item 2");
dummyData.Add("test item 3");
dummyData.Add("test item 4");
dummyData.Add("test item 5");
dummyData.Add("test item 6");
DummyData = new ObservableCollection<string>(dummyData);
this.InitializeComponent();
}
private void lvDummyData_ItemClick(object sender, ItemClickEventArgs e)
{
var selectedData = e.ClickedItem;
this.Frame.Navigate(typeof(SidePage), selectedData);
}
Here I have an observable collection that I am filling with dummy data. Aside from that I have item click event from my listview and passing the parameter to my SideView
page.
Here is how my SideView page looks like:
<Page
x:Class="App1.SidePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="sidePage"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Name="txtResultDisplay" />
</Grid>
</Page>
And this is how my code behind looks like:
public SidePage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string selectedDummyData = e.Parameter as string;
if (selectedDummyData != null)
{
txtResultDisplay.Text = selectedDummyData;
}
base.OnNavigatedTo(e);
}
Here we have an OnNavigatedTo
event which we can get passed parameteres.
This is the part you are lacking so please pay attention. Hope this helps resolve your problem.