(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

The ComboBox control in Silverlight

(5 votes)
Denislav Savkov
>
Denislav Savkov
Joined Feb 11, 2008
Articles:   14
Comments:   6
More Articles
4 comments   /   posted on Oct 13, 2008
Categories:   Controls

This article is compatible with the latest version of Silverlight.

Introduction

In this article we are going to explore some of the features of the ComboBox. Also we change the look of the control using a few templates based on the default control templates. You can see all the source code here.

Download source.

ComboBox and ListBox

The ComboBox control is very similar to the ListBox control. It derives from ItemsControl and Selector, it has ItemContainer property but it also has a few additional things that are connected with the drop down items menu. Using the events DropDownClosed, DropDownOpened and IsDropDownOpen(bool) you can keep track of it. MaxDropDownHeight limits the height of the drop down area. IsSelectionBoxHighlighted indicates weather the control has focus and the drop down menu is opened. Except SelectedItems and SelectedIndex ComboBox has SelectionBoxItem and SelectionBoxItemTemplate that give you access to the selected item that is displayed outside the drop down menu.

Making templates for the ComboBox

ComboBox has 5 states and 4 parts. To work properly you need to create a template that has all of them. However, hat's not all. To fully customize the ComboBox you also need to make template for ToggleButton, ComboBoxItem(ContentControl) and ScrollViewer. So there are plenty of templates you need to create. To make things a little simpler we didn't make template for the ScrollViewer as it is not always necessary to place the items in ScrollViewer and is not defined as "TemplatePart" of the ComboBox.

Here is a list of all the states and parts you need to define in XAML to create fully operational templates. We took the library templates and slightly modified them.

ComboBox

States:

  • FocusStates
    • Unfocused
    • Focused
    • FocusedDropDown
  • CommonStates
    • Disabled
    • Normal
    • MouseOver

Parts:

  • Name="Popup", Type=typeof(Popup)
  • Name="ContentPresenter", Type=typeof(ContentPresenter)
  • Name="ContentPresenterBorder", Type=typeof(FrameworkElement)
  • Name="DropDownToggle", Type=typeof(ToggleButton)
 <ControlTemplate TargetType="ComboBox" x:Key="comboTemplate">
     <Grid>
         <vsm:VisualStateManager.VisualStateGroups>
             <vsm:VisualStateGroup x:Name="CommonStates">
                 <vsm:VisualStateGroup.Transitions>
                     <vsm:VisualTransition GeneratedDuration="00:00:00.1"/>
                 </vsm:VisualStateGroup.Transitions>
                 <vsm:VisualState x:Name="Normal"/>
                 <vsm:VisualState x:Name="MouseOver"/>
                  <vsm:VisualState x:Name="Disabled">
                      <Storyboard>
                          <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement"
 Storyboard.TargetProperty="(UIElement.Opacity)">
                              <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                      </Storyboard>
                  </vsm:VisualState>
              </vsm:VisualStateGroup>
              <vsm:VisualStateGroup x:Name="FocusStates">
                  <vsm:VisualState x:Name="Focused">
                      <Storyboard>
                          <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement"
 Storyboard.TargetProperty="(UIElement.Opacity)">
                              <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                      </Storyboard>
                  </vsm:VisualState>
                  <vsm:VisualState x:Name="Unfocused"/>
                  <vsm:VisualState x:Name="FocusedDropDown">
                      <Storyboard>
                          <ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetName="PopupBorder"
 Storyboard.TargetProperty="(UIElement.Visibility)">
                              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                  <DiscreteObjectKeyFrame.Value>
                                      <Visibility>Visible</Visibility>
                                  </DiscreteObjectKeyFrame.Value>
                              </DiscreteObjectKeyFrame>
                          </ObjectAnimationUsingKeyFrames>
                      </Storyboard>
                  </vsm:VisualState>
              </vsm:VisualStateGroup>
         </vsm:VisualStateManager.VisualStateGroups>
          <Border x:Name="ContentPresenterBorder">
              <Grid>
                  <ToggleButton HorizontalAlignment="Stretch" 
                                x:Name="DropDownToggle"
                                Style="{StaticResource comboToggleStyle}" 
                                VerticalAlignment="Stretch" 
                                Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" >
                  </ToggleButton>
                  <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    x:Name="ContentPresenter" >
                      <TextBlock Text=" "/>
                  </ContentPresenter>
              </Grid>
          </Border>
          <Rectangle x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" Fill="#A5FFFFFF"/>
          <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Opacity="0" Stroke="#FF45D6FA"
 StrokeThickness="1"/>
          <Popup x:Name="Popup" Margin="-1">
              <Border Height="Auto" HorizontalAlignment="Stretch"
                      x:Name="PopupBorder" 
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}">
                  <ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1">
                      <ScrollViewer.Background>
                          <SolidColorBrush Color="{TemplateBinding Background}" Opacity="0"/>
                      </ScrollViewer.Background>
                      <ItemsPresenter/>
                  </ScrollViewer>
              </Border>
          </Popup>
      </Grid>
  </ControlTemplate>

ToggleButton States:

  • CommonStates
    • Disabled
    • Normal
    • MouseOver
    • Pressed
  • FocusStates
    • Unfocused
    • Focused

XAML

 <Style TargetType="ToggleButton" x:Name="comboToggleStyle">
     <Setter Property="Foreground" Value="#FF333333"/>
     <Setter Property="Background" Value="#441F3B53"/>
     <Setter Property="BorderBrush">
         <Setter.Value>
             <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                 <GradientStop Color="#FFA3AEB9" Offset="0"/>
                 <GradientStop Color="#FF8399A9" Offset="0.375"/>
                 <GradientStop Color="#FF718597" Offset="0.375"/>
                  <GradientStop Color="#FF617584" Offset="1"/>
              </LinearGradientBrush>
          </Setter.Value>
      </Setter>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Padding" Value="3"/>
      <Setter Property="Template">
          <Setter.Value>
              <ControlTemplate TargetType="ToggleButton">
                  <Grid>
                      <vsm:VisualStateManager.VisualStateGroups>
                          <vsm:VisualStateGroup x:Name="CommonStates">
                              <vsm:VisualStateGroup.Transitions>
                                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                              </vsm:VisualStateGroup.Transitions>
                              <vsm:VisualState x:Name="Normal"/>
                              <vsm:VisualState x:Name="MouseOver">
                                  <Storyboard>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundOverlay"
 Storyboard.TargetProperty="Opacity">
                                          <SplineDoubleKeyFrame KeyTime="0" Value=".4"/>
                                      </DoubleAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                  </Storyboard>
                              </vsm:VisualState>
                              <vsm:VisualState x:Name="Pressed">
                                  <Storyboard>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundOverlay2"  Storyboard.TargetProperty="Opacity">
                                          <SplineDoubleKeyFrame KeyTime="0" Value="1" />
                                      </DoubleAnimationUsingKeyFrames>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Highlight" 
                                            Storyboard.TargetProperty="(UIElement.Opacity)">
                                          <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                      </DoubleAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#E5FFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#BCFFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#6BFFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                  </Storyboard>
                              </vsm:VisualState>
                              <vsm:VisualState x:Name="Disabled">
                                  <Storyboard>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement"  Storyboard.TargetProperty="(UIElement.Opacity)">
                                          <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                      </DoubleAnimationUsingKeyFrames>
                                  </Storyboard>
                              </vsm:VisualState>
                          </vsm:VisualStateGroup>
                          <vsm:VisualStateGroup x:Name="CheckStates">
                              <vsm:VisualState x:Name="Checked">
                                  <Storyboard>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundOverlay3"  Storyboard.TargetProperty="(UIElement.Opacity)">
                                          <SplineDoubleKeyFrame KeyTime="0" Value="0.4"/>
                                      </DoubleAnimationUsingKeyFrames>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Highlight" 
                                               Storyboard.TargetProperty="(UIElement.Opacity)">
                                          <SplineDoubleKeyFrame KeyTime="0" Value="0.4"/>
                                      </DoubleAnimationUsingKeyFrames>
                                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient2"  Storyboard.TargetProperty="(UIElement.Opacity)">
                                          <SplineDoubleKeyFrame KeyTime="0" Value="0.4"/>
                                      </DoubleAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient2"  Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#E5FFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient2"
 Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#BCFFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient2"
 Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#6BFFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                      <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient2"
 Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                          <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
                                      </ColorAnimationUsingKeyFrames>
                                  </Storyboard>
                              </vsm:VisualState>
                              <vsm:VisualState x:Name="Unchecked"/>
                          </vsm:VisualStateGroup>
                          <vsm:VisualStateGroup x:Name="FocusStates">
                              <vsm:VisualState x:Name="Focused">
                                  <Storyboard>
                                      <ObjectAnimationUsingKeyFrames Duration="0"
 Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                                          <DiscreteObjectKeyFrame KeyTime="0">
                                              <DiscreteObjectKeyFrame.Value>
                                                  <Visibility>Visible</Visibility>
                                              </DiscreteObjectKeyFrame.Value>
                                          </DiscreteObjectKeyFrame>
                                      </ObjectAnimationUsingKeyFrames>
                                  </Storyboard>
                              </vsm:VisualState>
                              <vsm:VisualState x:Name="Unfocused"/>
                          </vsm:VisualStateGroup>
                      </vsm:VisualStateManager.VisualStateGroups>
                      <Rectangle x:Name="Background" RadiusX="3" RadiusY="3" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
                      <Rectangle x:Name="BackgroundOverlay" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" Stroke="#00000000" StrokeThickness="{TemplateBinding BorderThickness}"/>
                      <Rectangle x:Name="BackgroundOverlay2" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" Stroke="#00000000" StrokeThickness="{TemplateBinding BorderThickness}"/>
                      <Rectangle Margin="{TemplateBinding BorderThickness}" x:Name="BackgroundGradient" RadiusX="2" RadiusY="2" Stroke="#FFFFFFFF" StrokeThickness="1">
                          <Rectangle.Fill>
                              <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                  <GradientStop Color="#AAFFFFFF" Offset="0"/>
                                  <GradientStop Color="#88FFFFFF" Offset="0.375"/>
                                  <GradientStop Color="#55FFFFFF" Offset="0.625"/>
                                  <GradientStop Color="#33FFFFFF" Offset="1"/>
                              </LinearGradientBrush>
                          </Rectangle.Fill>
                      </Rectangle>
                      <Rectangle x:Name="BackgroundOverlay3" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" Stroke="#00000000" StrokeThickness="{TemplateBinding BorderThickness}"/>
                      <Rectangle Margin="{TemplateBinding BorderThickness}" x:Name="BackgroundGradient2" Opacity="0" RadiusX="2" RadiusY="2" Stroke="#FFFFFFFF" StrokeThickness="1">
                          <Rectangle.Fill>
                              <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                  <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                  <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                                  <GradientStop Color="#E5FFFFFF" Offset="0.625"/>
                                  <GradientStop Color="#C6FFFFFF" Offset="1"/>
                              </LinearGradientBrush>
                          </Rectangle.Fill>
                      </Rectangle>
                      <Rectangle Margin="{TemplateBinding BorderThickness}"
                                 x:Name="Highlight"
                                 IsHitTestVisible="false"
                                 Opacity="0" 
                                 RadiusX="2" RadiusY="2"
                                 Stroke="#FF45D6FA" StrokeThickness="1"/>
                      <ContentPresenter 
                                        x:Name="contentPresenter"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Content="{TemplateBinding Content}"
                                        ContentTemplate="{TemplateBinding ContentTemplate}"/>
                      <Rectangle x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" RadiusX="3" RadiusY="3" Fill="#A5FFFFFF"/>
                      <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" RadiusX="3.5" RadiusY="3.5" Stroke="#FF45D6FA" StrokeThickness="1"/>
                  </Grid>
              </ControlTemplate>
          </Setter.Value>
      </Setter>
  </Style>

ComboBoxItem States:

  • CommonStates
    • MouseOver
    • Normal
  • SelectionStates
    • Unselected
    • Selected
    • SelectedUnfocused
  • FocusStates
    • Focused  Note! To focus on item without MouseOver use the keyboard and not the mouse.
    • Unfocused

XAML

 <Style x:Key="ContainerStyle2" TargetType="ComboBoxItem">
     <Style.Setters>
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="ComboBoxItem">
                     <Grid >
                         <!-- VisualStateManager -->
                         <VisualStateManager.VisualStateGroups>
  
                              <!-- Common States-->
                              <VisualStateGroup x:Name="CommonStates">
   
                                  <!-- Normal -->
                                  <VisualState x:Name="Normal">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectNormal" Storyboard.TargetProperty="Opacity" To=".2"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectMouseOver" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectDisabled" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectPressed" Storyboard.TargetProperty="Opacity" To="0"/>
                                      </Storyboard>
                                  </VisualState>
   
                                  <!-- MouseOver -->
                                  <VisualState x:Name="MouseOver">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectNormal" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectMouseOver" Storyboard.TargetProperty="Opacity" To=".7"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectDisabled" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectPressed" Storyboard.TargetProperty="Opacity" To="0"/>
                                      </Storyboard>
                                  </VisualState>
   
                                  <!-- Disabled -->
                                  <VisualState x:Name="Disabled">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectNormal" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectMouseOver" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectDisabled" Storyboard.TargetProperty="Opacity" To=".7"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectPressed" Storyboard.TargetProperty="Opacity" To="0"/>
                                      </Storyboard>
                                  </VisualState>
   
                                  <VisualStateGroup.Transitions>
                                      <VisualTransition GeneratedDuration="0:0:0.1" />
                                  </VisualStateGroup.Transitions>
                              </VisualStateGroup>
   
                              <VisualStateGroup x:Name="FocusStates">
   
                                  <VisualState x:Name="Focused">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectFocused" Storyboard.TargetProperty="Opacity" To=".5"/>
                                         <DoubleAnimation Duration="0" Storyboard.TargetName="rectUnfocused" Storyboard.TargetProperty="Opacity" To="0"/>
                                      </Storyboard>
                                  </VisualState>
                                  <VisualState x:Name="Unfocused">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectFocused" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectUnfocused" Storyboard.TargetProperty="Opacity" To=".5"/>
                                      </Storyboard>
                                  </VisualState>
                                  <VisualStateGroup.Transitions>
                                      <VisualTransition GeneratedDuration="0:0:0.1"/>
                                  </VisualStateGroup.Transitions>
                              </VisualStateGroup>
   
   
                              <VisualStateGroup x:Name="SelectionStates">
                                  
                                  <VisualState x:Name="Selected">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectSelected" Storyboard.TargetProperty="Opacity" To=".4"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectUnselected" Storyboard.TargetProperty="Opacity" To="0"/>
                                      </Storyboard>
                                  </VisualState>
                                  
                                  <VisualState x:Name="Unselected">
                                      <Storyboard>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectSelected" Storyboard.TargetProperty="Opacity" To="0"/>
                                          <DoubleAnimation Duration="0" Storyboard.TargetName="rectUnselected" Storyboard.TargetProperty="Opacity" To=".3"/>
                                      </Storyboard>
                                  </VisualState>
                                  <VisualStateGroup.Transitions>
                                      <VisualTransition GeneratedDuration="0:0:0.1"/>
                                  </VisualStateGroup.Transitions>
                              </VisualStateGroup>
   
                          </VisualStateManager.VisualStateGroups>
   
                          <Rectangle x:Name="rectNormal"  Fill="LightPink" Opacity="0"/>
   
                          <Rectangle x:Name="rectFocused"  Fill="SkyBlue" Opacity="0"/>
                          <Rectangle x:Name="rectUnfocused"  Fill="Transparent"  Opacity="0"/>
   
                          <Rectangle x:Name="rectSelected"  Fill="LightGreen" Opacity="0"/>
                          <Rectangle x:Name="rectUnselected"  Fill="White" Opacity="0"/>
                          <ContentPresenter/>
                          <Border x:Name="rectMouseOver"  BorderBrush="BlueViolet" BorderThickness="2">
                              <Rectangle Fill="LightBlue" Opacity="0"/>
                          </Border>
                          <Rectangle x:Name="rectDisabled"  Fill="LightGray" Opacity="0"/>
                          <Rectangle x:Name="rectPressed"  Fill="DarkBlue" Opacity="0"/>
   
                      </Grid>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
      </Style.Setters>
  </Style>

Subscribe

Comments

  • -_-

    RE: The ComboBox control in Silverlight 2


    posted by Brijesh Patil on Jan 13, 2009 04:17

    Treeview in ComboBox is my requirement.

    The problem is I am able to display the treeview in combobox but I am not able to display the selected item from treeview to the combobox. Please let me know any clarifications

  • -_-

    RE: The ComboBox control in Silverlight 2


    posted by goldbishop on May 23, 2009 16:25
    Is there a way to put a watermark on the load of the control?  like "Select ????"
  • -_-

    RE: The ComboBox control in Silverlight 2


    posted by goldbishop on May 23, 2009 17:02
    nvm found it....thanx for the attempt if you were trying.
  • -_-

    RE: The ComboBox control in Silverlight


    posted by Torak on Jan 30, 2011 08:53

    I love how you have to rip apart the whole fucking control template to change the color-style of the combo box. Must be the same genius who hard-coded the white background into the button.

    Seriously guys ? wtf ?

Add Comment

Login to comment:
  *      *