您的位置:首页 > Web前端 > CSS

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: