WPF使用Prism框架首页界面

  1. 首先确保已经下载了NuGet包MaterialDesignThemes

2.我们通过包的项目URL可以跳转到Github上查看源码

3.找到首页所在的代码位置

4.将代码复制下来,删除掉自己不需要的东西,最终如下

cs 复制代码
<materialDesign:DialogHost
    DialogTheme="Inherit"
    Identifier="RootDialog"
    SnackbarMessageQueue="{Binding ElementName=MainSnackbar, Path=MessageQueue}">

    <materialDesign:DrawerHost IsLeftDrawerOpen="{Binding ElementName=MenuToggleButton, Path=IsChecked}">
        <materialDesign:DrawerHost.LeftDrawerContent>
            <!--  左侧菜单  -->
            <DockPanel MinWidth="220" />
        </materialDesign:DrawerHost.LeftDrawerContent>

        <!--  头部  -->
        <DockPanel>
            <materialDesign:ColorZone
                Padding="16"
                materialDesign:ElevationAssist.Elevation="Dp4"
                DockPanel.Dock="Top"
                Mode="PrimaryMid">
                <DockPanel>
                    <StackPanel Orientation="Horizontal">
                        <ToggleButton
                            x:Name="MenuToggleButton"
                            AutomationProperties.Name="HamburgerToggleButton"
                            IsChecked="False"
                            Style="{StaticResource MaterialDesignHamburgerToggleButton}" />

                        <Button
                            Margin="24,0,0,0"
                            materialDesign:RippleAssist.Feedback="{Binding RelativeSource={RelativeSource Self}, Path=Foreground, Converter={StaticResource BrushRoundConverter}}"
                            Command="{Binding MovePrevCommand}"
                            Content="{materialDesign:PackIcon Kind=ArrowLeft,
                                                              Size=24}"
                            Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"
                            Style="{StaticResource MaterialDesignToolButton}"
                            ToolTip="Previous Item" />

                        <Button
                            Margin="16,0,0,0"
                            materialDesign:RippleAssist.Feedback="{Binding RelativeSource={RelativeSource Self}, Path=Foreground, Converter={StaticResource BrushRoundConverter}}"
                            Command="{Binding MoveNextCommand}"
                            Content="{materialDesign:PackIcon Kind=ArrowRight,
                                                              Size=24}"
                            Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"
                            Style="{StaticResource MaterialDesignToolButton}"
                            ToolTip="Next Item" />

                        <Button
                            Margin="16,0,0,0"
                            materialDesign:RippleAssist.Feedback="{Binding RelativeSource={RelativeSource Self}, Path=Foreground, Converter={StaticResource BrushRoundConverter}}"
                            Command="{Binding HomeCommand}"
                            Content="{materialDesign:PackIcon Kind=Home,
                                                              Size=24}"
                            Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"
                            Style="{StaticResource MaterialDesignToolButton}"
                            ToolTip="Home" />
                    </StackPanel>


                    <TextBlock
                        Margin="-152,0,0,0"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        AutomationProperties.Name="Material Design In XAML Toolkit"
                        FontSize="22"
                        Text="Material Design In XAML Toolkit" />
                </DockPanel>
            </materialDesign:ColorZone>

        </DockPanel>
    </materialDesign:DrawerHost>
</materialDesign:DialogHost>

5.运行查看效果

相关推荐
张保瑞5 分钟前
十一:java web(3)-- Spring框架 -- Spring简介
java·前端·spring
墨柳烟29 分钟前
ABAQUS高亮显示网格节点方法:Python为每个节点建立集合
开发语言·前端·python·abaqus
琴~~1 小时前
前端根据后端返回的文本流逐个展示文本内容
前端·javascript·vue
zhaocarbon1 小时前
el-scrollbar 动态更新内容 鼠标滚轮无效
前端·javascript·vue.js
小码编匠1 小时前
WPF 自定义按钮样式(添加依赖属性、圆角)
后端·c#·.net
dangoxiba1 小时前
[Unity Demo]从零开始制作空洞骑士Hollow Knight第十八集补充:制作空洞骑士独有的EventSystem和InputModule
游戏·unity·c#·游戏引擎·playmaker
一纸忘忧1 小时前
Nuxt 3.14 发布!全新功能与性能提升
前端·javascript·vue.js
无敌最俊朗@2 小时前
unity3d————屏幕坐标,GUI坐标,世界坐标的基础注意点
开发语言·学习·unity·c#·游戏引擎
~甲壳虫2 小时前
react中得类组件和函数组件有啥区别,怎么理解这两个函数
前端·react.js·前端框架
Olivia_vivi2 小时前
WPF XAML
ui·wpf