I have a MainWindow, that has several pages, and a frame to navigate
All my pages have their ViewModel.
This is the code to navigate
private void PasgeSelectionItem(ModernWpf.Controls.Frame frame) {
frame?.Navigate(SelectedItem?.NavLink);
if (SelectedItem!.Name.Equals("CntactUS")) {
SendEmail();
}
if (SelectedItem.Name.Equals("acc")) {
if (!string.IsNullOrEmpty(UserId)) {
try {
ProfilePage profile = new ProfilePage() {
DataContext = new ProfilePageViewModel(UserId)
};
frame?.Navigate(SelectedItem.NavLink);
} catch (Exception ex) {
Debug.WriteLine(ex.Message);
}
}
The problem is that even though I set up my view Model for the profile page, and passed the UserID when it navigates, my bindings don't work
<Grid
Margin="20"
Background="DarkBlue">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="20" />
<RowDefinition Height="60" />
<RowDefinition Height="60" />
<RowDefinition Height="60" />
<RowDefinition />
</Grid.RowDefinitions>
<Ellipse
Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Top">
<Ellipse.Fill>
<ImageBrush ImageSource="/Images/Placeholder.png" />
</Ellipse.Fill>
</Ellipse>
<Separator Grid.Row="1" />
<TextBox
Grid.Row="2"
Margin="20,0,20,0"
VerticalAlignment="Center"
ui:ControlHelper.CornerRadius="10"
ui:ControlHelper.PlaceholderText="{x:Static res:Lang.Username}"
Foreground="Red"
Text="{Binding UserData[0].Object.Username}" />
<TextBox
Grid.Row="3"
Margin="20,0,20,0"
VerticalAlignment="Center"
ui:ControlHelper.CornerRadius="10"
ui:ControlHelper.PlaceholderText="{x:Static res:Lang.FirstName}"
Foreground="Red"
IsReadOnly="{Binding IsReadOnly}"
Text="{Binding UserData[0].Object.FirstName}" />
<TextBox
Grid.Row="4"
Margin="20,0,20,0"
VerticalAlignment="Center"
ui:ControlHelper.CornerRadius="10"
ui:ControlHelper.PlaceholderText="{x:Static res:Lang.LastName}"
Foreground="Red"
IsReadOnly="{Binding IsReadOnly}"
Text="{Binding UserData[0].Object.LastName}" />
<Button
Grid.Row="5"
Margin="20,0,20,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
ui:ControlHelper.CornerRadius="10"
Content="{Binding BtonContent}" />
I also tried to send y userID to the profile page and then to the vm, but I get Null exemption when navigating
Code: https://github.com/eduardoagr/TranscribeMe