Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF Combobox

WPF Combobox

Scheduled Pinned Locked Moved WPF
csharpwpfhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koleraba
    wrote on last edited by
    #1

    Hi I am trying to change the look of the ComboBox when it is disabled. I want to change it's background and border. I tried the most common aproach with triggers but that did not work. Than I tried changing the template but could not find the part that should be changed. Does anybody has a solution for my problem? Any advice will be appreciated. Uros

    V 1 Reply Last reply
    0
    • K koleraba

      Hi I am trying to change the look of the ComboBox when it is disabled. I want to change it's background and border. I tried the most common aproach with triggers but that did not work. Than I tried changing the template but could not find the part that should be changed. Does anybody has a solution for my problem? Any advice will be appreciated. Uros

      V Offline
      V Offline
      vsaratkar
      wrote on last edited by
      #2

      Try this:-

      <Style.Triggers>
      <Trigger Property="IsEnabled" Value="false">
      <Setter Property="Template" >
      <Setter.Value>
      <ControlTemplate TargetType="ComboBox">
      <Grid>
      <Grid.ColumnDefinitions>
      <ColumnDefinition />
      <ColumnDefinition Width="20" />
      </Grid.ColumnDefinitions>
      <Border
      Grid.ColumnSpan="2"
      CornerRadius="2"
      Background="Red"
      BorderBrush="Green"/>
      <Border
      Grid.Column="0"
      CornerRadius="2,0,0,2"
      Margin="1"
      Background="Yellow"
      BorderBrush="Black"
      />
      <Path
      Grid.Column="1"
      Fill="Aqua"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"
      Data="M 0 0 L 4 4 L 8 0 Z"/>
      </Grid>
      </ControlTemplate>
      </Setter.Value>
      </Setter>
      </Trigger>
      </Style.Triggers>

      In XAML:-

      hth, v

      K 1 Reply Last reply
      0
      • V vsaratkar

        Try this:-

        <Style.Triggers>
        <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Template" >
        <Setter.Value>
        <ControlTemplate TargetType="ComboBox">
        <Grid>
        <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition Width="20" />
        </Grid.ColumnDefinitions>
        <Border
        Grid.ColumnSpan="2"
        CornerRadius="2"
        Background="Red"
        BorderBrush="Green"/>
        <Border
        Grid.Column="0"
        CornerRadius="2,0,0,2"
        Margin="1"
        Background="Yellow"
        BorderBrush="Black"
        />
        <Path
        Grid.Column="1"
        Fill="Aqua"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Data="M 0 0 L 4 4 L 8 0 Z"/>
        </Grid>
        </ControlTemplate>
        </Setter.Value>
        </Setter>
        </Trigger>
        </Style.Triggers>

        In XAML:-

        hth, v

        K Offline
        K Offline
        koleraba
        wrote on last edited by
        #3

        Thanks for your reply - it works great. Maybe just one more thing. ComboBox with this style doesn't show the selected item(text) when disabled. I tried adding a TextBlock to one of the border's but I don't know to what should be bind to. Any ideas? Thanks again for your help. Uros

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups