wpf Combobox 样式的问题
2013-04-02 17:19
495 查看
<!-- Combobox--> <Style x:Key="ComboBoxReadonlyToggleButton" TargetType="ToggleButton"> <Setter Property="IsTabStop" Value="false" /> <Setter Property="ClickMode" Value="Press" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToggleButton"> <Grid> <Border x:Name="Background" BorderBrush="#FFBF97F2" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4"> <Border.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF0C1E5D" /> <GradientStop Color="#FF2C409D" Offset="0.487" /> <GradientStop Color="#FF0F256C" Offset="1" /> </LinearGradientBrush> </Border.Background> <Path x:Name="Path" Height="Auto" Margin="0,0.082,0,8.859" Width="Auto" Stretch="Fill" Stroke="{x:Null}" StrokeLineJoin="Round" StrokeThickness="1" Data="M0,3 C0,1.3431457 1.3431457,0 3,0 L129,0 C130.65686,0 132,1.3431457 132,3 L132,13.853975 C86.718803,0.055481441 26.160202,27.400364 0,11.585506 z"> <Path.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#005B3D7A" Offset="0.113" /> <GradientStop Color="#FF7AA0F2" Offset="1" /> </LinearGradientBrush> </Path.Fill> </Path> </Border> <Path Height="10" x:Name="Path1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,7,0" Width="10" Fill="#FF2B1C3C" Stretch="Fill" Stroke="#FFBF97F2" Data="M0.5,0.5 L9.5,0.5 L5.0625,9.5 L5.0625,9.5 z" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="DefaultComboBoxStyle" TargetType="ComboBox"> <Setter Property="Foreground" Value="#FFFFFFFF" /> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF032C58" /> <GradientStop Color="#FF032854" Offset="0.61699998378753662" /> <GradientStop Color="#FF072449" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="#FFFFFFFF" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="Padding" Value="4,3" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ComboBox"> <Grid x:Name="MainGrid"> <Grid.RowDefinitions> <RowDefinition Height="30"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Popup x:Name="PART_Popup" Margin="1" Grid.Row="1" IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"> <Grid x:Name="Shdw" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding Path=ActualWidth, ElementName=MainGrid}"> <Border x:Name="DropDownBorder" BorderBrush="#FFFFFFFF" BorderThickness="1 0 1 1" CornerRadius="3"> <!--Background --> <Border CornerRadius="2"> <Border.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF375698" Offset="0.013" /> <GradientStop Color="#FF5F87DC" Offset="0.61699998378753662" /> <GradientStop Color="#FF3B62B7" Offset="1" /> </LinearGradientBrush> </Border.Background> <ScrollViewer Width="150"> <ItemsPresenter /> </ScrollViewer> </Border> </Border> </Grid> </Popup> <ToggleButton Style="{StaticResource ComboBoxReadonlyToggleButton}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" /> <ContentPresenter Margin="40 0 0 0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" IsHitTestVisible="false" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
本文转载 http://www.aaspx.com/thread-105-1-1.html
相关文章推荐
- WPF ComboBox样式
- wpf 样式问题
- WPF样式中使用BasedOn 注意顺序问题
- 关于WPF的ComboBox中Items太多而导致加载过慢的问题(转载)
- wpf 样式问题
- wpf ComboBox 绑定 以及绑定项过多加载过慢问题
- 关于WPF的ComboBox中Items太多而导致加载过慢的问题
- wpf Combobox没有黑三角,鼠标移上去改变样式
- 【WPF】ComboBoxItem 奇偶样式
- WPF开发中遇到的问题及解决系列(二):如何获取通过binding生成的ComboBox或者ListBox等的Item
- WPF中样式使用问题记录
- 关于WPF的ComboBox中Items太多而导致加载过慢的问题
- WPF中ComboBox控件显示的样式设置
- 潜移默化学会WPF(样式篇)---改造ComboBox,全新metro风格
- WPF的Combobox的ItemSource第二次绑定(更新)问题
- WPF中Button的样式重写后的focus的样式问题
- 求助 WPF ListViewItem样式问题
- WPF按钮清空自带样式,以及透明按钮时,Grid的Background属性设置引起"点击"问题.
- WPF ComboBox样式 分类: .NET 2015-05-11 14:06 515人阅读 评论(0) 收藏
- 【WPF】修改ComboBox样式