WPF下Itemscontrol分组 样式
来源:互联网 发布:linux msdos 编辑:程序博客网 时间:2024/05/16 00:37
<ItemsControl Grid.Row="1" DataContext="{Binding Layouts}" ItemsSource="{Binding }">
<ItemsControl.GroupStyle>
<GroupStyle >
<GroupStyle.ContainerStyle >
<Style TargetType="{x:Type GroupItem}" >
<Setter Property="Margin" Value="0,0,0,10"/>
<Setter Property="Template" >
<Setter.Value >
<ControlTemplate TargetType="{x:Type GroupItem}">
<Border BorderBrush="Gray" BorderThickness="1" Margin="5,6,5,1">
<StackPanel >
<ContentPresenter />
<Border >
<ItemsPresenter />
</Border>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
<GroupStyle.HeaderTemplate >
<DataTemplate >
<TextBlock Name="txtgroup" FontSize="13" Foreground="#262679" Text="基本布局"/>
<DataTemplate.Triggers >
<DataTrigger Binding="{Binding Path=Name}" Value="Increase">
<Setter TargetName="txtgroup" Property="Text" Value="增强布局" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate >
<DataTemplate >
<Button Command="{Binding SelectedStyleCommand}" CommandParameter="{Binding Tag}" Background="{Binding Img}"
Width="120" Height="80" Margin="10,10,0,10">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bd001" CornerRadius="8" Background="{TemplateBinding Background}" BorderBrush="LightGray" BorderThickness="2">
<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers >
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85" TargetName="bd001"/>
<Setter Property="BorderBrush" Value="Red" TargetName="bd001"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel >
<ItemsPanelTemplate >
<UniformGrid Rows="2" Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<!--<ItemsControl.ItemContainerStyle >
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="Red" />
</MultiTrigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>-->
</ItemsControl>
<ItemsControl.GroupStyle>
<GroupStyle >
<GroupStyle.ContainerStyle >
<Style TargetType="{x:Type GroupItem}" >
<Setter Property="Margin" Value="0,0,0,10"/>
<Setter Property="Template" >
<Setter.Value >
<ControlTemplate TargetType="{x:Type GroupItem}">
<Border BorderBrush="Gray" BorderThickness="1" Margin="5,6,5,1">
<StackPanel >
<ContentPresenter />
<Border >
<ItemsPresenter />
</Border>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
<GroupStyle.HeaderTemplate >
<DataTemplate >
<TextBlock Name="txtgroup" FontSize="13" Foreground="#262679" Text="基本布局"/>
<DataTemplate.Triggers >
<DataTrigger Binding="{Binding Path=Name}" Value="Increase">
<Setter TargetName="txtgroup" Property="Text" Value="增强布局" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate >
<DataTemplate >
<Button Command="{Binding SelectedStyleCommand}" CommandParameter="{Binding Tag}" Background="{Binding Img}"
Width="120" Height="80" Margin="10,10,0,10">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bd001" CornerRadius="8" Background="{TemplateBinding Background}" BorderBrush="LightGray" BorderThickness="2">
<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers >
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85" TargetName="bd001"/>
<Setter Property="BorderBrush" Value="Red" TargetName="bd001"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel >
<ItemsPanelTemplate >
<UniformGrid Rows="2" Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<!--<ItemsControl.ItemContainerStyle >
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="Red" />
</MultiTrigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>-->
</ItemsControl>
- WPF下Itemscontrol分组 样式
- WPF(ContentControl和ItemsControl)
- WPF(Binding of ItemsControl)
- WPF/silverlight ItemsControl 解析
- ControlTemplate in WPF —— ItemsControl
- Wpf itemsControl listbox 虚拟化平滑滚动
- WPF中动态加载数据<ItemsControl>
- WPF部分总结ItemsControl,Thumb,画图,动画
- WPF 样式
- WPF样式
- WPF 样式
- wpf样式
- WPF 样式
- WPF样式
- WPF-ListBox分组-排序
- WPF,ListView设置分组
- C#中WPF下自定义滚动条ScrollViewer样式
- WPF初学者之WPF样式
- 常用正则表达式大全!(例如:匹配中文、匹配html)
- Ftp客户端java类库
- Android环境应用开发配置
- 人生
- 适用于Java程序员的通信顺序进程
- WPF下Itemscontrol分组 样式
- VS写的程序-游戏在未安装VS的电脑上运行
- 如何改变Android Progressbar默认颜色
- Sql2005中Datetime类型用Like查找的问题
- ajax 提交转码encodeURIComponent
- to_char取日期-年月日
- ejb三种bean之会话bean
- Android APK反编译详解(附图)
- dbcp 连接配置属性详解