Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify control template slightly using Style

I just need to add a thick border around the ComboBox. As you may already know, ComboBox's BorderThickness property is not of much use. So I'm trying to modify the Template using following style, but can't figure out what I need to write inside the Border tag to represent the ComoboBox itself:

<Style TargetType="{x:Type ComboBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ComboBox">
                <Border BorderBrush="Black" BorderThickness="2">
                    WHAT GOES HERE?
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

I have tried ContentPresenter and ContentControl but honestly don't know much about their usage in this particular scenario.

like image 669
dotNET Avatar asked Dec 06 '25 03:12

dotNET


1 Answers

Well if I get you right, you want to put the original ComboBox in that Border, right? You can find an example template customization here.
So if you copy the important part (the Grid) in your Border it should look like the standard ComboBox with a thicker Border. Perhaps you will have to do some minor modifications, so that it looks perfect. Btw, MS Blend would be a great help here.

like image 85
DHN Avatar answered Dec 08 '25 17:12

DHN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!