Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,768 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi, I want to modify the width of combo box control scroll bar. thanks .
You can use below methods to modify the width of comboBox ScrollBar.
Method 1:
<ComboBox Name="com"
HorizontalAlignment="Left"
Margin="335,176,0,0"
VerticalAlignment="Top"
MaxDropDownHeight="100"
Width="130" >
<ComboBox.Resources>
<Style TargetType="{x:Type ScrollViewer}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="VerticalScrollBarVisibility" Value="Visible"></Setter>
<Setter Property="HorizontalScrollBarVisibility" Value="Visible"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter Grid.Column="1"/>
<ScrollBar Name="PART_VerticalScrollBar" Grid.Row="0" Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Right"
Width="38" Value="{TemplateBinding VerticalOffset}"
Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}"
/>
<ScrollBar Name="PART_HorizontalScrollBar" Grid.Row="1" Grid.Column="1"
Orientation="Horizontal" Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Popup">
<Setter Property="Width" Value="130"/>
</Style>
</ComboBox.Resources>
</ComboBox>
Method 2: Add namespace xmlns:sys="clr-namespace:System;assembly=mscorlib"
<ComboBox Name="com2"
HorizontalAlignment="Left"
VerticalAlignment="Top"
MaxDropDownHeight="100"
Margin="30 100 20 100"
Width="130" >
<ComboBox.Resources>
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">50</sys:Double>
<sys:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">50</sys:Double>
</ComboBox.Resources>
</ComboBox>
Method 3:
<ComboBox Name="com3"
HorizontalAlignment="Left"
VerticalAlignment="Top"
MaxDropDownHeight="100"
Width="130" >
<ComboBox.Resources>
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="Stylus.IsFlicksEnabled" Value="True" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Height" Value="35" />
<Setter Property="MinHeight" Value="40" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="35" />
<Setter Property="MinWidth" Value="40" />
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Resources>
</ComboBox>
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Excellent answers, works like a champ