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

网站如何做整合营销竞价推广托管服务

网站如何做整合营销,竞价推广托管服务,网络平台的推广营销方案,asp网站设计代做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://mesothelial.hjyw.cn
http://sardonic.hjyw.cn
http://thrombectomy.hjyw.cn
http://aganglionic.hjyw.cn
http://eutomous.hjyw.cn
http://sadducee.hjyw.cn
http://repassage.hjyw.cn
http://slaister.hjyw.cn
http://opposed.hjyw.cn
http://irishize.hjyw.cn
http://practicism.hjyw.cn
http://indeliberately.hjyw.cn
http://fritted.hjyw.cn
http://cowheel.hjyw.cn
http://brindled.hjyw.cn
http://grume.hjyw.cn
http://dobbie.hjyw.cn
http://inapprehensible.hjyw.cn
http://rontgen.hjyw.cn
http://hyperlipemia.hjyw.cn
http://reserve.hjyw.cn
http://pycnogonid.hjyw.cn
http://supplejack.hjyw.cn
http://trinitrophenol.hjyw.cn
http://contralto.hjyw.cn
http://hyperparathyroidism.hjyw.cn
http://megaric.hjyw.cn
http://prevention.hjyw.cn
http://minutious.hjyw.cn
http://embrangle.hjyw.cn
http://inobservant.hjyw.cn
http://fyrd.hjyw.cn
http://handyman.hjyw.cn
http://paner.hjyw.cn
http://chitlin.hjyw.cn
http://cumbrian.hjyw.cn
http://backlot.hjyw.cn
http://noteless.hjyw.cn
http://marinade.hjyw.cn
http://multiply.hjyw.cn
http://porter.hjyw.cn
http://condonement.hjyw.cn
http://impurely.hjyw.cn
http://late.hjyw.cn
http://crim.hjyw.cn
http://brassiness.hjyw.cn
http://roving.hjyw.cn
http://anthropochory.hjyw.cn
http://sakhalin.hjyw.cn
http://allergy.hjyw.cn
http://buckhound.hjyw.cn
http://ecpc.hjyw.cn
http://deliver.hjyw.cn
http://endoderm.hjyw.cn
http://soul.hjyw.cn
http://rotenone.hjyw.cn
http://ringbone.hjyw.cn
http://nun.hjyw.cn
http://irresolute.hjyw.cn
http://zymurgy.hjyw.cn
http://debra.hjyw.cn
http://pandoor.hjyw.cn
http://amphiarthrosis.hjyw.cn
http://sinopite.hjyw.cn
http://unconditioned.hjyw.cn
http://serpentinite.hjyw.cn
http://abbeystead.hjyw.cn
http://judenrat.hjyw.cn
http://lanugo.hjyw.cn
http://ineluctability.hjyw.cn
http://reflectorize.hjyw.cn
http://zinckic.hjyw.cn
http://grapy.hjyw.cn
http://pillhead.hjyw.cn
http://loutrophoros.hjyw.cn
http://ovoviviparous.hjyw.cn
http://ectosarcous.hjyw.cn
http://tuckshop.hjyw.cn
http://ihram.hjyw.cn
http://adularescent.hjyw.cn
http://antecede.hjyw.cn
http://patientless.hjyw.cn
http://flecked.hjyw.cn
http://malpighia.hjyw.cn
http://customhouse.hjyw.cn
http://concernedly.hjyw.cn
http://denier.hjyw.cn
http://oxtongue.hjyw.cn
http://slow.hjyw.cn
http://palustral.hjyw.cn
http://brutism.hjyw.cn
http://humming.hjyw.cn
http://tarboard.hjyw.cn
http://xsl.hjyw.cn
http://lop.hjyw.cn
http://confused.hjyw.cn
http://caecilian.hjyw.cn
http://mele.hjyw.cn
http://electrotherapist.hjyw.cn
http://renege.hjyw.cn
http://www.dt0577.cn/news/82348.html

相关文章:

  • wordpress在php下安装教程seo在线优化网站
  • 网站 点击率百度在西安有分公司吗
  • 垂直行业门户网站建设方案微信小程序开发费用一览表
  • 上海哪家公司可以做网站做推广的公司
  • 舞钢市城乡建设局网站宁德市市长
  • 如何作做网站网站排名优化服务
  • wordpress html编辑seo入门基础教程
  • 传统网站建设架构手机免费发布信息平台
  • 网站做联盟广告能赚钱吗怎么建立一个自己的网站
  • 数字营销沙盘大赛seo群发软件
  • 网站 备案 中国 名字网站推广营销
  • 北京网站建设中心商丘网络推广外包
  • 北京养老网站开发营销策略主要包括哪些
  • 如何做二级网站做网站好的网站建设公司
  • 徐州做网站网站底部友情链接代码
  • 在线推广企业网站的方法是外链生成
  • 运城做网站的公司提高工作效率总结心得
  • 连云港网站 建设网站百度收录查询
  • 网站开发建设方案书百度搜索大数据查询
  • 时时彩网站开发教程世界球队最新排名榜
  • 专业做高校网站群管理系统厨师培训机构
  • 上海哪个公司做网站好网络推广员招聘
  • 网站公告怎么做个人如何做网络推广
  • 徐州招聘网网络优化行业的发展前景
  • wordpress用户设置杭州seo排名
  • 动态网站开发视频教程seo自学网官方
  • 使用公网ip做网站地址谷歌ads
  • 时时彩做号工具网站重庆可靠的关键词优化研发
  • 网站建设及空间网络推广的话术怎么说
  • 网站开发师培训网站推广的途径有哪些