Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends

is there any possible to create sample rounded corner combobox in wpf. if there means please tel the sample
Posted
Comments
Mark Salsbery 7-Nov-11 15:40pm    
Both solutions are correct - the code at the link leaves out all the control parts in the "..." section. Just wanted to mention, if you have Blend you can easily get a copy of the template and manually adjust all the border radii as desired.

XML
<Window.Resources>
        <ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}">
            <Border Background="{TemplateBinding Background}" 
                x:Name="Bd" BorderBrush="Black"
                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10">
                <ScrollViewer x:Name="PART_ContentHost"/>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
                <Trigger Property="Width" Value="Auto">
                    <Setter Property="MinWidth" Value="100"/>
                </Trigger>
                <Trigger Property="Height" Value="Auto">
                    <Setter Property="MinHeight" Value="20"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>
    <Grid>
        <ComboBox Template="{StaticResource TextBoxBaseControlTemplate}" Margin="144,107,253,168"/>
    </Grid>
</Window>
 
Share this answer
 
You don't need anything but Border:

XML
<Border BorderThickness="1.2 1.2 0 0" CornerRadius="3.2" BorderBrush="Black" Background="Yellow" Height="20" Margin="6">
    <Border BorderThickness="0 0 1.2 1.2" CornerRadius="3.2" BorderBrush="White" Padding="1">
        <TextBlock Width="130" Height="30" Background="Transparent" TextAlignment="Center">Some Text</TextBlock>
    </Border>
</Border>


—SA
 
Share this answer
 
v3
You have to write your own custom template from scratch. make your first control a border in the template a border with corner radius set to something greater than 0
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Nov-11 18:27pm    
There is much, much simpler solution. Look at my sample -- it shows "3D" border with rounded corners. All the trick is in Border.
--SA
 
Share this answer
 
Comments
Nivas Maran 7-Nov-11 5:32am    
mr patel i tried that code but the drop down button doesnt work and cant able to add item
Venkatesh Mookkan 7-Nov-11 6:05am    
Post what you did so far. That might help us to find your problem.
Sergey Alexandrovich Kryukov 7-Nov-11 18:28pm    
Right, a 5.
The solution is quite simple. Look at my sample -- it shows "3D" border with rounded corners. All the trick is in Border.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900