Skip to content

Instantly share code, notes, and snippets.

Created September 9, 2014 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/847ebc1fe3bd16611df4 to your computer and use it in GitHub Desktop.
Save anonymous/847ebc1fe3bd16611df4 to your computer and use it in GitHub Desktop.
<Grid
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:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" mc:Ignorable="d"
d:DesignWidth="1743" d:DesignHeight="1024"
TextElement.FontFamily="Fonts/#Arimo"
TextElement.FontWeight="Bold"
TextElement.FontSize="16">
<Grid.Resources>
<!--<Style x:Key="ComboBoxFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="0,0,0,0" SnapsToDevicePixels="true" Stroke="#FF555555" StrokeThickness="1" StrokeDashArray="1 2" HorizontalAlignment="Stretch"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>-->
<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#F3F3F3" Offset="0"/>
<GradientStop Color="#EBEBEB" Offset="0.5"/>
<GradientStop Color="#DDDDDD" Offset="0.5"/>
<GradientStop Color="#CDCDCD" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
<LinearGradientBrush x:Key="TextBoxBorder" EndPoint="0,20" MappingMode="Absolute" StartPoint="0,0">
<GradientStop Color="#ABADB3" Offset="0.05"/>
<GradientStop Color="#E2E3EA" Offset="0.07"/>
<GradientStop Color="#E3E9EF" Offset="1"/>
</LinearGradientBrush>
<Style x:Key="ComboBoxTestStyle" TargetType="{x:Type ComboBox}">
<!--<Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>-->
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
<Setter Property="Padding" Value="0,0"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid x:Name="MainGrid" SnapsToDevicePixels="true">
<Popup x:Name="PART_Popup"
AllowsTransparency="true"
IsOpen="{TemplateBinding IsDropDownOpen}"
Margin="0"
PopupAnimation="Slide" >
<Grid x:Name="DropDown"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{TemplateBinding ActualWidth}">
<!--<Border x:Name="DropDownBorder" BorderThickness="0">-->
<ScrollViewer x:Name="DropDownScrollViewer"
VerticalScrollBarVisibility="Disabled">
<!--<Grid>-->
<!--<Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
<Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}" FlowDirection="LeftToRight" StrokeThickness="0"/>
</Canvas>-->
<ItemsPresenter x:Name="ItemsPresenter"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Margin="0"/>
<!--<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />-->
<!--</Grid>-->
</ScrollViewer>
<!--</Border>-->
</Grid>
</Popup>
<ToggleButton
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
<ContentPresenter
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Content="{TemplateBinding SelectionBoxItem}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsHitTestVisible="false"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#FFBBBBBB"/>
<Setter Property="Background" Value="#FFF4F4F4"/>
</Trigger>
<!--<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
<Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
<Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
</Trigger>-->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border Name="Grid" Background="Transparent" Margin="0,5,0,0" >
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFF0F0F0" Offset="0"/>
<GradientStop Color="#FFAAAAAA" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<ComboBox HorizontalAlignment="Center"
Margin="0,0,50,0"
VerticalAlignment="Center"
Width="40" Height="40"
SelectedIndex="1"
Background="#FFD4D4D4"
MaxDropDownHeight="800"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Style="{DynamicResource ComboBoxTestStyle}">
<Border Width="40" Height="40" Background="#FF9C9C9C"/>
<Border Width="40" Height="40" Background="#FF636363"/>
<Border Width="40" Height="40" Background="#FFD8D8D8"/>
<Border Width="40" Height="40" Background="#FF4D4D4D"/>
<Border Width="40" Height="40" Background="#FF5F3939"/>
</ComboBox>
</Grid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment