SL3 Nav framework + MVVM ligh
- by Murari
Hi All, Thanks for taking time to read through my question. Any guidance is really appreciated.
I am using SL3 Navigation framework in my LOB application. I m currently using MVVM Light as the framework guidance.
I have a datagrid consisting of employees and when the "user" clicks on "employee id link" in the datagrid, i am transferring the user to "Edit Page". I would like to transfer the "employee id" as query parameter to "edit page".
The issue here is: I can access the query parameter in the EditStaffView.xaml.cs - which i don't want to do.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (this.NavigationContext.QueryString.ContainsKey("staffcode"))
{
string title = this.NavigationContext.QueryString["staffcode"];
}
}
I would like to retrieve the query parameter in my viewmodel and based on the query parameter, i will perform certain operations. When the constructor is called I would like the "view" to pass the staffid as shown below
public EditStaffViewModel(int staffId)
{
LoadData(staffId);
}
I am constructing my hyperlink buttons in the datagrid dyanmically as shown below:
staffListingModel.HyperlinkNavigationUri = string.Format("{0}{1}", NavigationUri.DataEntryEditStaff,"?staffcode={" + staffListingModel.StaffCode + "}");
and XAML looks
HyperlinkButton
Content="{Binding StaffCode,Mode=TwoWay}" NavigateUri="{Binding HyperlinkNavigationUri}" HyperlinkButton
Any idea how to do this ??
Thanks for the help.
Murari