Skip to content

Add new menu

Sichlan edited this page Jan 11, 2022 · 2 revisions
  1. Create View and ViewModel
  2. Add DataTemplates to App.xaml:
    <DataTemplate DataType="{x:Type viewModels:VIEWMODEL}">
        <views:VIEW />
    </DataTemplate>
    
  3. Add page type as enumeration value to ViewType (ViewType.cs)
  4. Add ViewModel as transient service to AddViewModelsHostBuilderExtensions in region ViewModels:
    services.AddTransient<VIEWMODEL>();
    
  5. Add creation delegate to AddViewModelsHostBuilderExtensions in region Delegates:
    services.AddSingleton<CreateViewModel<VIEWMODEL>>(s => s.GetRequiredService<VIEWMODEL>);
    
  6. Add creation delegate and entry for the enum value to ApocryphaViewModelFactory
  7. MENU ONLY - Add menu button for the new page in NavigationBar.xaml:
    <RadioButton
        IsChecked="{Binding CurrentViewModel, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewModels:VIEWMODEL}, Mode=OneWay}"
        Command="{Binding UpdateCurrentViewModelCommand}"
        CommandParameter="{x:Static navigators:ViewType.VIEWMODELENUM}">
        <StackPanel Orientation="Horizontal">
            <ContentControl Template="{StaticResource PAGEICON}" Width="20" Height="20"
                VerticalAlignment="Center" Foreground="{StaticResource BrushForeground1}"/>
            <TextBlock Text="{x:Static res:Localization.PAGENAMERESOURCE}" Margin="10 0 0 0"
                Visibility="{Binding MenuExpanded, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
                VerticalAlignment="Center" />
        </StackPanel>
    </RadioButton>
    

Clone this wiki locally