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

相关推荐
web小白成长日记3 小时前
企业级 Vue3 + Element Plus 主题定制架构:从“能用”到“好用”的进阶之路
前端·架构
APIshop4 小时前
Python 爬虫获取 item_get_web —— 淘宝商品 SKU、详情图、券后价全流程解析
前端·爬虫·python
风送雨4 小时前
FastMCP 2.0 服务端开发教学文档(下)
服务器·前端·网络·人工智能·python·ai
XTTX1104 小时前
Vue3+Cesium教程(36)--动态设置降雨效果
前端·javascript·vue.js
LYFlied5 小时前
WebGPU与浏览器边缘智能:开启去中心化AI新纪元
前端·人工智能·大模型·去中心化·区块链
Setsuna_F_Seiei5 小时前
2025 年度总结:人生重要阶段的一年
前端·程序员·年终总结
李建军5 小时前
界止签章宗地号替换工具
c#
qq_425263325 小时前
.net开发框架和语言
c#
model20055 小时前
alibaba linux3 系统盘网站迁移数据盘
java·服务器·前端
武藤一雄5 小时前
C# 关于多线程如何实现需要注意的问题(持续更新)
windows·后端·microsoft·c#·.net·.netcore·死锁