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

相关推荐
mCell1 天前
GSAP ScrollTrigger 详解
前端·javascript·动效
gnip1 天前
Node.js 子进程:child_process
前端·javascript
hez20101 天前
Runtime Async - 步入高性能异步时代
c#·.net·.net core·clr
excel1 天前
为什么在 Three.js 中平面能产生“起伏效果”?
前端
excel1 天前
Node.js 断言与测试框架示例对比
前端
天蓝色的鱼鱼1 天前
前端开发者的组件设计之痛:为什么我的组件总是难以维护?
前端·react.js
codingandsleeping1 天前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
石金龙1 天前
[译] Composition in CSS
前端·css
白水清风1 天前
微前端学习记录(qiankun、wujie、micro-app)
前端·javascript·前端工程化
Ticnix1 天前
函数封装实现Echarts多表渲染/叠加渲染
前端·echarts