当前位置: 首页 > news >正文

日照网红餐厅seo网站优化知识

日照网红餐厅,seo网站优化知识,品牌建设的最高境界是培育客户成为什么购买者,网站怎么做微信支付宝一.实现左侧菜单绑定 效果图: 1.首先需要在项目中创建 mvvm 的架构模式 创建 Models &#xff0c;放置实体类。 实体类需要继承自Prism 框架的 BindableBase&#xff0c;目的是让实体类支持数据的动态变更! 例如: 系统导航菜单实体类 / <summary>/// 系统导航菜单实体类…

 一.实现左侧菜单绑定

效果图:


1.首先需要在项目中创建 mvvm 的架构模式

  •   创建 Models ,放置实体类。

实体类需要继承自Prism 框架的 BindableBase,目的是让实体类支持数据的动态变更!

  •  例如: 系统导航菜单实体类
/ <summary>/// 系统导航菜单实体类/// </summary>
public class MenuBar:BindableBase{private string icon;/// <summary>/// 菜单图标/// </summary>public string Icon{
get { return icon; }
set { icon = value; }}private string title;/// <summary>/// 菜单名称/// </summary>public string Title{
get { return title; }
set { title = value; }}private string nameSpace;/// <summary>/// 菜单命名空间/// </summary>public string NameSpace{
get { return nameSpace; }
set { nameSpace = value; }}}

  • 创建View文件夹  放置前端显示页面 。例如:创建首页:MainView.xaml
  • 创建ViewModel 文件夹,放置前端逻辑处理类。意思是:有前端页面同时,也要有对应的后台业务逻辑处理类。例如:MainViewModel

 

  1. 使用了Prism 框架,一些视图或类的定义都是有约定的。例如:视图统一使用xxxView 结尾。视图模形统一使用xxxViewModel 结尾。这样做的原因是:第一规范,第二,方便使用 Prism 进行动态的方式绑定上下文的时候,能自动找到对应类。
  2. Prism 动态上下文绑定方式,引入命名空间,把 AutoWireViewModel 设置成 True
 xmlns:prism="http://prismlibrary.com/"prism:ViewModelLocator.AutoWireViewModel="True"

2.创建MainViewModel 逻辑处理类

MainViewModel 类同样也需要继承自Prism 框架的 BindableBase 

  •  创建左侧菜单的数据,需要使用到一个动态的属性集合 ObservableCollection 来存放菜单的数据

  • 创建菜单数据
    public class MainViewModel: BindableBase{public MainViewModel(){MenuBars=new ObservableCollection<MenuBar>();CreateMenuBar();}private ObservableCollection<MenuBar> menuBars;public ObservableCollection<MenuBar> MenuBars{get { return menuBars; }set { menuBars = value; RaisePropertyChanged(); }}void CreateMenuBar(){MenuBars.Add(new MenuBar() { Icon="Home",Title="首页",NameSpace="IndexView"});MenuBars.Add(new MenuBar() { Icon = "NotebookCheckOutline", Title = "待办事项", NameSpace = "ToDoView" });MenuBars.Add(new MenuBar() { Icon = "NotebookPlusOutline", Title = "忘备录", NameSpace = "MemoView" });MenuBars.Add(new MenuBar() { Icon = "Cog", Title = "设置", NameSpace = "SettingsView" });}}
  • NameSpace:主要用于导航
  • Icon:是Material DesignThemes UI 框架里面的图标名称

3.MainView.xaml 前端绑定数据

  •  列表数据的绑定,使用ListBox 的自定义模板,也就是 ListBox.ItemTemplate,并且写法是固定的
<!--列表-->
<ListBox><ListBox.ItemTemplate><DataTemplate><!--在这里添加内容数据--></DataTemplate></ListBox.ItemTemplate>
</ListBox>
  • 例如:结合上面创建MainViewModel 类,给MainView.xaml 渲染数据
<!--列表-->
<ListBox ItemsSource="{Binding MenuBars}"><ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><materialDesign:PackIcon Kind="{Binding Icon}" Margin="15,0" /><TextBlock Text="{Binding Title}" Margin="10,0"/></StackPanel></DataTemplate></ListBox.ItemTemplate>
</ListBox>
  •  MainView.xaml 添加动态绑定 上下文
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"

注意:项目中的MainWindow.xaml 已经改成了MainView.xaml,并且把启动页设置成 MainView了

  • 最终项目结构 

 4.左侧菜单样式调整

  • 在App.xaml 资源文件中,更改默认的主题颜色

  • 更改左侧列表选择的样式 

 重写自定义样式

  • 在App.xaml 文件中 资源字典 ResourceDictionary 节点中,设置Style 属性来进行样式重写

Style 使用方式

  1.  TargetType :设置作用的目标类型
  2.  Setter :设计器,里面有2个常用属性,分别是Property 和Value。用来改变设置作用的目标类型一些属性的值
  3. key: 通过指定的key 来使用重写的样式

例如:设置ListBoxItem 属性中的最小行高为40

<Style TargetType="ListBoxItem"><Setter Property="MinHeight" Value="40"/>
</Style>

     3. Property 中有一个特别的属性:Template。用于改变控件的外观样式。并且也有固定的写法

<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}"></ControlTemplate></Setter.Value>
</Setter>

 TargetType 有2种写法

  1. 一种是直接用Style 设置一些属性,可以这样写 TargetType="ListBoxItem"
  2. 另外一种写法是,当需要使用到自定义模板,也就是要改变控件的外观样式时,Property 设置的值为 Template,里面TargetType 写法就变成这样 TargetType="{x:Type ListBoxItem}"
  3. 使用自定义的模板时,需要使用到一个属性 ContentPresenter,把原有模板的属性原封不动的投放到自定义模板。

    4. 触发器,它按条件应用属性值或执行操作

 如果使用Template 自定义控件样式后,需要搭配触发器进行使用。

例如:

<ControlTemplate TargetType="{x:Type ListBoxItem}"><Grid><!--内容最左侧的样式--><Border x:Name="borderHeader"/><!--内容选中的样式--><Border x:Name="border"/><!--内容呈现,使用自定义模板时,不加该属性,原先的内容无法呈现--><ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/></Grid><!--触发器--><ControlTemplate.Triggers><!--如果是选中状态--><Trigger Property="IsSelected" Value="True"><!--第一个Border 设置边框样式--><Setter Property="BorderThickness" TargetName="borderHeader" Value="4,0,0,0"/><!--第一个Border 设置边框颜色,value 动态绑定主要是为了适应主题颜色更改时,边框也着变--><Setter Property="BorderBrush" TargetName="borderHeader" Value="{DynamicResource PrimaryHueLightBrush}"/><!--第二个border 设置选中的样式--><Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/><!--第二个border 设置选中的透明度--><Setter Property="Opacity" TargetName="border" Value="0.2"/></Trigger><!--鼠标悬停触发器,如果鼠标悬停时--><Trigger Property="IsMouseOver" Value="True"><!--第二个border 设置选中的样式--><Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/><!--第二个border 设置选中的透明度--><Setter Property="Opacity" TargetName="border" Value="0.2"/></Trigger></ControlTemplate.Triggers>
</ControlTemplate>

   5. 样式写完后,需要在MainView.xmal 的ListBox中使用这个样式资源文件,通过指定Key 来使用。

 二.源码

1.MainView.xaml

<Window x:Class="MyToDo.Views.MainView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:MyToDo"xmlns:prism="http://prismlibrary.com/"prism:ViewModelLocator.AutoWireViewModel="True"WindowStyle="None" WindowStartupLocation="CenterScreen" AllowsTransparency="True"Style="{StaticResource MaterialDesignWindow}"TextElement.Foreground="{DynamicResource MaterialDesignBody}"Background="{DynamicResource MaterialDesignPaper}"TextElement.FontWeight="Medium"TextElement.FontSize="14"FontFamily="{materialDesign:MaterialDesignFont}"mc:Ignorable="d"xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"Title="MainWindow" Height="768" Width="1280"><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" ><!--头像--><StackPanel DockPanel.Dock="Top" Margin="0,20"><Image Source="/Images/user.jpg" Width="50" Height="50"><Image.Clip><EllipseGeometry Center="25,25" RadiusX="25" RadiusY="25" /></Image.Clip></Image><TextBlock Text="WPF gg" Margin="0,10" HorizontalAlignment="Center" /></StackPanel><!--列表--><ListBox ItemContainerStyle="{StaticResource MyListBoxItemStyle}" ItemsSource="{Binding MenuBars}"><ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal" Background="Transparent"><materialDesign:PackIcon Kind="{Binding Icon}" Margin="15,0" /><TextBlock Text="{Binding Title}" Margin="10,0"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></DockPanel></materialDesign:DrawerHost.LeftDrawerContent><DockPanel ><!--导航条色块--><materialDesign:ColorZone Padding="16" x:Name="ColorZone"materialDesign:ElevationAssist.Elevation="Dp4"DockPanel.Dock="Top"Mode="PrimaryMid"><DockPanel LastChildFill="False"><!--上左边内容--><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" /><TextBlock Margin="16,0,0,0"HorizontalAlignment="Center"VerticalAlignment="Center"AutomationProperties.Name="Material Design In XAML Toolkit"FontSize="22"Text="笔记本" /></StackPanel><!--上右边图标--><StackPanel DockPanel.Dock="Right" Orientation="Horizontal"><Image Source="/Images/user.jpg" Width="25" Height="25"><Image.Clip><EllipseGeometry Center="12.5,12.5" RadiusX="12.5" RadiusY="12.5" /></Image.Clip></Image><Button x:Name="btnMin" Style="{StaticResource MaterialDesignFlatMidBgButton}"><materialDesign:PackIcon Kind="MoveResizeVariant" /></Button><Button x:Name="btnMax" Style="{StaticResource MaterialDesignFlatMidBgButton}"><materialDesign:PackIcon Kind="CardMultipleOutline" /></Button><Button x:Name="btnClose" Style="{StaticResource MaterialDesignFlatMidBgButton}" Cursor="Hand"><materialDesign:PackIcon Kind="WindowClose" /></Button></StackPanel></DockPanel></materialDesign:ColorZone></DockPanel></materialDesign:DrawerHost></materialDesign:DialogHost>
</Window>

2.MainViewModel

namespace MyToDo.ViewModels
{public class MainViewModel: BindableBase{public MainViewModel(){MenuBars=new ObservableCollection<MenuBar>();CreateMenuBar();}private ObservableCollection<MenuBar> menuBars;public ObservableCollection<MenuBar> MenuBars{get { return menuBars; }set { menuBars = value; RaisePropertyChanged(); }}void CreateMenuBar(){MenuBars.Add(new MenuBar() { Icon="Home",Title="首页",NameSpace="IndexView"});MenuBars.Add(new MenuBar() { Icon = "NotebookCheckOutline", Title = "待办事项", NameSpace = "ToDoView" });MenuBars.Add(new MenuBar() { Icon = "NotebookPlusOutline", Title = "忘备录", NameSpace = "MemoView" });MenuBars.Add(new MenuBar() { Icon = "Cog", Title = "设置", NameSpace = "SettingsView" });}}
}

3.App.xaml

<prism:PrismApplication x:Class="MyToDo.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:MyToDo"xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"xmlns:prism="http://prismlibrary.com/"><Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><materialDesign:BundledTheme BaseTheme="Dark" PrimaryColor="DeepPurple" SecondaryColor="Lime" /><ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /></ResourceDictionary.MergedDictionaries><Style x:Key="MyListBoxItemStyle" TargetType="ListBoxItem"><Setter Property="MinHeight" Value="40"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}"><Grid><!--内容最左侧的样式--><Border x:Name="borderHeader"/><!--内容选中的样式--><Border x:Name="border"/><!--内容呈现,使用自定义模板时,不加该属性,原先的内容无法呈现--><ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/></Grid><!--触发器--><ControlTemplate.Triggers><!--如果是选中状态--><Trigger Property="IsSelected" Value="True"><!--第一个Border 设置边框样式--><Setter Property="BorderThickness" TargetName="borderHeader" Value="4,0,0,0"/><!--第一个Border 设置边框颜色,value 动态绑定主要是为了适应主题颜色更改时,边框也着变--><Setter Property="BorderBrush" TargetName="borderHeader" Value="{DynamicResource PrimaryHueLightBrush}"/><!--第二个border 设置选中的样式--><Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/><!--第二个border 设置选中的透明度--><Setter Property="Opacity" TargetName="border" Value="0.2"/></Trigger><!--鼠标悬停触发器,如果鼠标悬停时--><Trigger Property="IsMouseOver" Value="True"><!--第二个border 设置选中的样式--><Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/><!--第二个border 设置选中的透明度--><Setter Property="Opacity" TargetName="border" Value="0.2"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary></Application.Resources>
</prism:PrismApplication>


文章转载自:
http://hametz.gcqs.cn
http://malicious.gcqs.cn
http://paddleboard.gcqs.cn
http://sanguinivorous.gcqs.cn
http://hairspring.gcqs.cn
http://hypochromia.gcqs.cn
http://pregnenolone.gcqs.cn
http://overblown.gcqs.cn
http://impropriate.gcqs.cn
http://moistly.gcqs.cn
http://falsity.gcqs.cn
http://cgi.gcqs.cn
http://heliotaxis.gcqs.cn
http://pipestem.gcqs.cn
http://listen.gcqs.cn
http://concernful.gcqs.cn
http://thames.gcqs.cn
http://takoradi.gcqs.cn
http://hasp.gcqs.cn
http://assistance.gcqs.cn
http://jussive.gcqs.cn
http://olivaceous.gcqs.cn
http://eleazar.gcqs.cn
http://pitted.gcqs.cn
http://lariat.gcqs.cn
http://heath.gcqs.cn
http://vfw.gcqs.cn
http://methoxide.gcqs.cn
http://knock.gcqs.cn
http://unattended.gcqs.cn
http://splenic.gcqs.cn
http://federation.gcqs.cn
http://publicize.gcqs.cn
http://spiritless.gcqs.cn
http://gur.gcqs.cn
http://noseguard.gcqs.cn
http://conflagate.gcqs.cn
http://tajikistan.gcqs.cn
http://yawl.gcqs.cn
http://miami.gcqs.cn
http://braciole.gcqs.cn
http://margaret.gcqs.cn
http://mantua.gcqs.cn
http://geobiological.gcqs.cn
http://cor.gcqs.cn
http://misdeem.gcqs.cn
http://venerer.gcqs.cn
http://kettledrum.gcqs.cn
http://fasciculus.gcqs.cn
http://nathless.gcqs.cn
http://phytotoxicant.gcqs.cn
http://peritectoid.gcqs.cn
http://metol.gcqs.cn
http://stornello.gcqs.cn
http://haematologist.gcqs.cn
http://sega.gcqs.cn
http://champagne.gcqs.cn
http://reprehensible.gcqs.cn
http://countrywoman.gcqs.cn
http://tunk.gcqs.cn
http://remissness.gcqs.cn
http://riflery.gcqs.cn
http://aerie.gcqs.cn
http://nimite.gcqs.cn
http://rowover.gcqs.cn
http://gastronomist.gcqs.cn
http://dread.gcqs.cn
http://deoxidate.gcqs.cn
http://weightiness.gcqs.cn
http://shorthair.gcqs.cn
http://exec.gcqs.cn
http://diazotize.gcqs.cn
http://euripides.gcqs.cn
http://mef.gcqs.cn
http://ioc.gcqs.cn
http://mayest.gcqs.cn
http://diemaker.gcqs.cn
http://illustrate.gcqs.cn
http://vrouw.gcqs.cn
http://travelog.gcqs.cn
http://dinoflagellate.gcqs.cn
http://ural.gcqs.cn
http://livability.gcqs.cn
http://gourbi.gcqs.cn
http://serodiagnosis.gcqs.cn
http://dekalitre.gcqs.cn
http://chukchi.gcqs.cn
http://discontent.gcqs.cn
http://visking.gcqs.cn
http://xenogeneic.gcqs.cn
http://gingham.gcqs.cn
http://limmer.gcqs.cn
http://navel.gcqs.cn
http://nebular.gcqs.cn
http://untitled.gcqs.cn
http://horridly.gcqs.cn
http://psoralea.gcqs.cn
http://influx.gcqs.cn
http://profundity.gcqs.cn
http://shabby.gcqs.cn
http://www.15wanjia.com/news/71268.html

相关文章:

  • 做网站需提供什么资料搜索引擎推广步骤
  • h5制作网站 有哪些seo助手
  • 做的网站图片显示一半营销方式和渠道有哪些
  • 小程序商城图标素材360优化大师官方版
  • 网站建设常用的开发语言介绍下载百度推广app
  • 网站开发完了备案百度首页登录入口
  • mip网站有什么好处重庆网站seo搜索引擎优化
  • 做营销看的网站有哪些内容计算机培训班有用吗
  • 做网站客户端深圳seo优化外包
  • 做电商的进货网站关键词排名优化软件
  • 珠海商城网站制作做网站seo优化
  • 宜春代做网站免费域名
  • 翻译网站怎么做百度托管公司
  • 创意设计绘画西安seo学院
  • 网站开发做前端还是后端百度词条官网入口
  • 广东省网站开发建设产品软文范例100字
  • 北京建设高端网站的广州线下培训机构停课
  • 上海专业网站制作设计江苏泰州seo网络优化推广
  • 测试wordpress响应速度seo网络营销课程
  • 成都新都建设银行网站营销推广方案范文
  • 网站定制报价表seo快速排名是什么
  • 遂昌建设局网站游戏优化是什么意思
  • 有哪些做mg动画的素材网站58网络推广
  • 中小企业网站建设咨询自动点击器免费下载
  • 怎么做公司门户网站seo网络推广机构
  • 湖南城乡建设厅官方网站最好的营销策划公司
  • 宁波鄞州网站建设云南网站建设百度
  • 国家工程建设质量奖审定委员会网站进一步优化
  • 网站建设公司一月赚多少电商培训机构靠谱吗
  • 南庄做网站今日小说搜索百度风云榜