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.运行查看效果

相关推荐
知识分享小能手9 分钟前
Bootstrap 5学习教程,从入门到精通,Bootstrap 5 表单验证语法知识点及案例代码(34)
前端·javascript·学习·typescript·bootstrap·html·css3
一只小灿灿24 分钟前
前端计算机视觉:使用 OpenCV.js 在浏览器中实现图像处理
前端·opencv·计算机视觉
前端小趴菜0536 分钟前
react状态管理库 - zustand
前端·react.js·前端框架
Jerry Lau1 小时前
go go go 出发咯 - go web开发入门系列(二) Gin 框架实战指南
前端·golang·gin
我命由我123452 小时前
前端开发问题:SyntaxError: “undefined“ is not valid JSON
开发语言·前端·javascript·vue.js·json·ecmascript·js
0wioiw02 小时前
Flutter基础(前端教程③-跳转)
前端·flutter
落笔画忧愁e2 小时前
扣子Coze纯前端部署多Agents
前端
海天胜景2 小时前
vue3 当前页面方法暴露
前端·javascript·vue.js
GISer_Jing2 小时前
前端面试常考题目详解
前端·javascript
Boilermaker19923 小时前
【Java EE】SpringIoC
前端·数据库·spring