Search code examples
uwpmvvm-lightwindows-template-studio

Windows Template Studio MVVM Light Navigation To Page--Not everything loads the first time on UWP app


I'm probably missing something fundamental, but don't know what.

I'm in the process of converting a Tempalate10 UWP app to Windows Template Studio.

I've got most of my code moved over to the new project, but what strikes me is that when a page is loaded (navigated to), not everything seems to load the first time. I try the second time and it loads everything. What am I missing?

Added code:

<StackPanel Visibility="{x:Bind ViewModel.ItemFinalized, Mode=OneWay}">
                            <TextBlock TextWrapping="WrapWholeWords">This text</TextBlock>
                            <ToggleSwitch x:Name="toggleSwitchSaveCopies2"
                                      Margin="0,0,0,0"
                                      IsOn="{x:Bind ViewModel.SavePdfCopies, Mode=TwoWay}"
                                      Visibility="{x:Bind ViewModel.HasLineItems, Mode=OneWay}"
                                      OffContent="Don't save PDF copies."
                                      OnContent="Save and show me the PDFs."></ToggleSwitch>
                            <ToggleSwitch x:Name="toggleSwitchComposeEmail2"
                                      Margin="0,0,0,0"
                                      IsOn="{x:Bind ViewModel.ComposeEmail, Mode=TwoWay}"
                                      OffContent="Don't compose an email."
                                      OnContent="Compose an email."></ToggleSwitch>
                            <Button x:Name="buttonSaveFinalized"
                                IsEnabled="{x:Bind ViewModel.CanSave, Mode=OneWay}"
                                Content="Save"
                                Margin="0,12,0,20"
                                Click="ButtonSaveFinalized_Click" />
                            <Button x:Name="buttonViewScanSheetPDF"
                                Content="Test"
                                Margin="0,25,0,20"
                                Click="ButtonViewScanSheetPDF_Click" />
                        </StackPanel>

ViewModel:

public bool ItemFinalized { get => itemFinalized; set { Set(ref itemFinalized, value); RaisePropertyChanged("IsDraft"); } }

Solution

  • To summarize what eventually worked:

    Mode=OneWay on x:Bind and Binding

    Adding more RaisePropertyChanged in certain Properties bound to XAML control Visibility