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

南通企业自助建站优化网站关键词优化

南通企业自助建站,优化网站关键词优化,网站做链接的意义是什么意思,百度seo现状WPF的数据绑定系统自动生成列表项对象,为单个项应用所需的样式不是很容易。解决方案是ItemContainerStyle 属性。如果设置了ItemContainerStyle 属性,当创建列表项时,列表控件会将其向下传递给每个项。对于ListBox控件,每个项有Li…

WPF的数据绑定系统自动生成列表项对象,为单个项应用所需的样式不是很容易。解决方案是ItemContainerStyle 属性。如果设置了ItemContainerStyle 属性,当创建列表项时,列表控件会将其向下传递给每个项。对于ListBox控件,每个项有ListBoxItem 对象表示,对于CombBox 控件,则对应是 CombBoxItem。

交替条目样式

WPF通过两个属性为交替项提供内置支持:AlternationCount 和 AlternationIndex。

<Window><Window.Resources><Style x:Key="listBoxItemStyle" TargetType="{x:Type ListBoxItem}"><Setter Property="Background" Value="LightBlue"/><Setter Property="Margin" Value="5"></Setter><Setter Property="Padding" Value="5"></Setter><Style.Triggers><Trigger Property="ItemsControl.AlternationIndex" Value="1"><Setter Property="Background" Value="LightBlue"/></Trigger><Trigger Property="IsSelected" Value="True"><Setter Property="Background" Value="DarkRed"/><Setter Property="Foreground" Value="White"/><Setter Property="BorderBrush" Value="Black"/><Setter Property="BorderThickness" Value="10"/></Trigger></Style.Triggers></Style></Window.Resources><Grid x:Name="myGrid"><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition MinHeight="100"/></Grid.RowDefinitions><ListBox Grid.Row="0" Grid.Column="0" ItemContainerStyle="{StaticResource listBoxItemStyle}" ItemsSource="{Binding Path=Orders}" AlternationCount="2" DisplayMemberPath="Price"/></Grid>
</Window>

也可以直接将样式设置到ListBox层次

<Window><Window.Resources><Style x:Key="checkBoxListStyle" TargetType="{x:Type ListBox}"><Setter Property="SelectionMode" Value="Multiple"></Setter><Setter Property="ItemContainerStyle"><Setter.Value><Style TargetType="{x:Type ListBoxItem}"><Setter Property="Margin" Value="2"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}"><CheckBox IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"><ContentPresenter/></CheckBox></ControlTemplate></Setter.Value></Setter></Style></Setter.Value></Setter></Style></Window.Resources><Grid x:Name="myGrid"><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition MinHeight="100"/></Grid.RowDefinitions><ListView Grid.Row="1" Grid.Column="0" Style="{StaticResource checkBoxListStyle}" ItemsSource="{Binding Path=Orders}" DisplayMemberPath="Price" Name="checkButtonListBox"/></Grid>
</Window>

样式选择器

可以使用样式选择器来为不同的子项提供不同的样式,自定义样式选择器需要继承自 StyleSelector 类,需要重写 SelectStyle() 方法。

public class SingleCriteriaHighlightStyleSelector : StyleSelector
{public Style DefaultStyle { get; set; }public Style HighlightStyle { get; set; }public string PropertyToEvaluate { get; set; }public string PropertyValueToHighlight { get; set; }public override Style SelectStyle(object item, DependencyObject container){Order order = (Order)item;if (order.Price > 1000){return HighlightStyle;}else{return DefaultStyle;}}
}

完整的代码文件:

MainWindow.xaml

<Window x:Class="ListBoxStyle.MainWindow"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:ListBoxStyle"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Window.Resources><Style x:Key="listBoxItemStyle" TargetType="{x:Type ListBoxItem}"><Setter Property="Background" Value="Blue"/><Setter Property="Margin" Value="5"></Setter><Setter Property="Padding" Value="5"></Setter><Style.Triggers><Trigger Property="ItemsControl.AlternationIndex" Value="1"><Setter Property="Background" Value="LightBlue"/></Trigger><Trigger Property="IsSelected" Value="True"><Setter Property="Background" Value="DarkRed"/><Setter Property="Foreground" Value="White"/><Setter Property="BorderBrush" Value="Black"/><Setter Property="BorderThickness" Value="10"/></Trigger></Style.Triggers></Style><Style x:Key="radioButtonListStyle" TargetType="{x:Type ListBoxItem}"><Setter Property="Background" Value="Blue"/><Setter Property="Margin" Value="5"></Setter><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}"><RadioButton Focusable="False" IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"><ContentPresenter/></RadioButton></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="checkBoxListStyle" TargetType="{x:Type ListBox}"><Setter Property="SelectionMode" Value="Multiple"></Setter><Setter Property="ItemContainerStyle"><Setter.Value><Style TargetType="{x:Type ListBoxItem}"><Setter Property="Margin" Value="2"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}"><CheckBox IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"><ContentPresenter/></CheckBox></ControlTemplate></Setter.Value></Setter></Style></Setter.Value></Setter></Style><Style x:Key="DefaultStyle" TargetType="{x:Type ListBoxItem}"><Setter Property="Background" Value="LightYellow" /><Setter Property="Padding" Value="2" /></Style><Style x:Key="HighlightStyle" TargetType="{x:Type ListBoxItem}"><Setter Property="Background" Value="LightSteelBlue" /><Setter Property="FontWeight" Value="Bold" /><Setter Property="Padding" Value="2" /></Style></Window.Resources><Grid x:Name="myGrid"><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition MinHeight="100"/></Grid.RowDefinitions><ListBox Grid.Row="0" Grid.Column="0" ItemContainerStyle="{StaticResource listBoxItemStyle}" ItemsSource="{Binding Path=Orders}" AlternationCount="3" DisplayMemberPath="Price"/><ListBox Grid.Row="0" Grid.Column="1" ItemContainerStyle="{StaticResource radioButtonListStyle}" ItemsSource="{Binding Path=Orders}" DisplayMemberPath="Price" Name="radioButtonListBox"/><ListView Grid.Row="1" Grid.Column="0" Style="{StaticResource checkBoxListStyle}" ItemsSource="{Binding Path=Orders}" DisplayMemberPath="Price" Name="checkButtonListBox"/><ListBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Path=Orders}" DisplayMemberPath="Price" Name="styleSelectorListBox"><ListBox.ItemContainerStyleSelector><local:SingleCriteriaHighlightStyleSelector DefaultStyle="{StaticResource DefaultStyle}" HighlightStyle="{StaticResource HighlightStyle}"></local:SingleCriteriaHighlightStyleSelector></ListBox.ItemContainerStyleSelector></ListBox><Button Grid.Row="4" Click="Button_Click">Test</Button><Button Grid.Row="4" Grid.Column="1" Click="Button_Click_1">Test</Button></Grid>
</Window>

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace ListBoxStyle;public class ViewModelBase : INotifyPropertyChanged
{public event PropertyChangedEventHandler? PropertyChanged;protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));}protected virtual bool SetProperty<T>(ref T member, T value, [CallerMemberName] string? propertyName = null){if (EqualityComparer<T>.Default.Equals(member, value)){return false;}member = value;OnPropertyChanged(propertyName);return true;}
}
public class Order : ViewModelBase
{public decimal price = 0;public decimal Price { get => price; set => SetProperty(ref price, value); }public int volume = 0;public int Volume { get => volume; set => SetProperty(ref volume, value); }public DateTime orderDate = DateTime.Now;public DateTime OrderDate { get => orderDate; set => SetProperty(ref orderDate, value); }public string image = string.Empty;public string Image { get => image; set => SetProperty(ref image, value); }
}public class SingleCriteriaHighlightStyleSelector : StyleSelector
{public Style DefaultStyle { get; set; }public Style HighlightStyle { get; set; }public string PropertyToEvaluate { get; set; }public string PropertyValueToHighlight { get; set; }public override Style SelectStyle(object item, DependencyObject container){Order order = (Order)item;if (order.Price > 1000){return HighlightStyle;}else{return DefaultStyle;}}
}public partial class MainWindow : Window
{public MainWindow(){InitializeComponent();myGrid.DataContext = this;Order order1 = new Order();Order order2 = new Order();Order order3 = new Order();Order order4 = new Order();order1.Price = 100;order1.Volume = 10;order2.Price = 1000;order2.Volume = 100;order3.Price = 10000;order3.Volume = 1000;order4.Price = 100000;order4.Volume = 10000;Orders.Add(order1);Orders.Add(order2);Orders.Add(order3);Orders.Add(order4);}public ObservableCollection<Order> Orders {get; set;} = new ();private void Button_Click(object sender, RoutedEventArgs e){string message = "";if(radioButtonListBox.SelectedItem != null){Order order = (Order)radioButtonListBox.SelectedItem;message = order.Price.ToString();}message += "\n";foreach (var selectedItem in checkButtonListBox.SelectedItems){Order order = (Order)selectedItem;message += order.Price.ToString() + " ";}MessageBox.Show(message);}private void Button_Click_1(object sender, RoutedEventArgs e){Orders[1].Price = 50000;StyleSelector selector = styleSelectorListBox.ItemContainerStyleSelector;styleSelectorListBox.ItemContainerStyleSelector = null;styleSelectorListBox.ItemContainerStyleSelector = selector;}
}


文章转载自:
http://terran.Lbqt.cn
http://cube.Lbqt.cn
http://disseise.Lbqt.cn
http://wring.Lbqt.cn
http://cassegrainian.Lbqt.cn
http://pinguin.Lbqt.cn
http://deadlock.Lbqt.cn
http://holand.Lbqt.cn
http://vacuolating.Lbqt.cn
http://hythergraph.Lbqt.cn
http://isolead.Lbqt.cn
http://snifter.Lbqt.cn
http://sprowsie.Lbqt.cn
http://rpm.Lbqt.cn
http://streakily.Lbqt.cn
http://ocean.Lbqt.cn
http://daffy.Lbqt.cn
http://drizzle.Lbqt.cn
http://peregrinator.Lbqt.cn
http://glaciate.Lbqt.cn
http://undernourish.Lbqt.cn
http://retrace.Lbqt.cn
http://countergirl.Lbqt.cn
http://fetichist.Lbqt.cn
http://tranquilite.Lbqt.cn
http://kalendar.Lbqt.cn
http://equinoctial.Lbqt.cn
http://pyralid.Lbqt.cn
http://toolhouse.Lbqt.cn
http://lameness.Lbqt.cn
http://courses.Lbqt.cn
http://froze.Lbqt.cn
http://subcontraoctave.Lbqt.cn
http://sower.Lbqt.cn
http://sapsucker.Lbqt.cn
http://unwitnessed.Lbqt.cn
http://deductive.Lbqt.cn
http://farthest.Lbqt.cn
http://lyrebird.Lbqt.cn
http://wharfinger.Lbqt.cn
http://revanchist.Lbqt.cn
http://dumb.Lbqt.cn
http://amtrac.Lbqt.cn
http://kilodyne.Lbqt.cn
http://purline.Lbqt.cn
http://wicket.Lbqt.cn
http://alienism.Lbqt.cn
http://crystallogenesis.Lbqt.cn
http://chromizing.Lbqt.cn
http://sgm.Lbqt.cn
http://soundful.Lbqt.cn
http://calorific.Lbqt.cn
http://laggardly.Lbqt.cn
http://kenyon.Lbqt.cn
http://pathoformic.Lbqt.cn
http://basil.Lbqt.cn
http://arrear.Lbqt.cn
http://ibidine.Lbqt.cn
http://mendicity.Lbqt.cn
http://neomycin.Lbqt.cn
http://herbartianism.Lbqt.cn
http://bedmate.Lbqt.cn
http://meritocrat.Lbqt.cn
http://hexobiose.Lbqt.cn
http://skeptic.Lbqt.cn
http://shippen.Lbqt.cn
http://gobang.Lbqt.cn
http://galilean.Lbqt.cn
http://refundable.Lbqt.cn
http://treaty.Lbqt.cn
http://hydrasorter.Lbqt.cn
http://nowanights.Lbqt.cn
http://mrcs.Lbqt.cn
http://moabitess.Lbqt.cn
http://roentgenoparent.Lbqt.cn
http://mondrian.Lbqt.cn
http://malison.Lbqt.cn
http://transplacental.Lbqt.cn
http://increment.Lbqt.cn
http://sonable.Lbqt.cn
http://pareira.Lbqt.cn
http://invalid.Lbqt.cn
http://upwhirl.Lbqt.cn
http://garrison.Lbqt.cn
http://viand.Lbqt.cn
http://nomism.Lbqt.cn
http://anelectric.Lbqt.cn
http://lumpenproletarian.Lbqt.cn
http://vulturish.Lbqt.cn
http://mattery.Lbqt.cn
http://rosy.Lbqt.cn
http://ejectamenta.Lbqt.cn
http://pachisi.Lbqt.cn
http://syria.Lbqt.cn
http://rosaria.Lbqt.cn
http://scarlatina.Lbqt.cn
http://autoeciousness.Lbqt.cn
http://fort.Lbqt.cn
http://returnable.Lbqt.cn
http://actinomycin.Lbqt.cn
http://www.15wanjia.com/news/98959.html

相关文章:

  • 网站维护的作用百度最新秒收录方法2021
  • 做网站包括哪些免费crm系统手机版
  • 水果网站策划方案seo建站需求
  • 学平面设计网站武汉seo公司哪家好
  • 做理财网站公司网站模版
  • 昌江县住房和城乡建设局网站推广app的平台
  • 网推公司怎么收费手机360优化大师官网
  • 建设企业网站的企业微信管理助手
  • 橱柜企业网站模板推广app用什么平台比较好
  • 网站制作什么样的字体好看58同城关键词怎么优化
  • POS机网站怎么做站长工具友链查询
  • 做网站怎么推广站长工具网址查询
  • 建设网站小常识温州seo服务
  • 长春市土建公司seo网络推广公司报价
  • b战网站建设策划书互联网广告推广公司
  • 自适应网站css 写法湖南网站推广公司
  • 兼职做网站这样的网站河北seo推广方案
  • 建网站需要什么软件电商网站如何避免客户信息泄露
  • ps做网站显示内容参考百度搜索广告推广
  • wordpress searchform百度seo排名如何提升
  • 东营优化路网关键词优化快速排名
  • 做外贸哪个网站最好全国各城市疫情搜索高峰进度
  • 做网站好几个css百度快照首页
  • 上海做网站报价色盲测试图免费测试
  • 中国做外贸网站有哪些快速排名程序
  • 五八同城客服网站怎么做个人网页免费域名注册入口
  • 怎么在网上做装修网站媒体平台
  • 长春网站建设制作莆田seo推广公司
  • 如何做网站认证一键建站
  • 佛山网站建设灵格百度浏览器官网下载并安装