Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am trying to change the scrollbar in the listbox. I try'd many way to Change that. If the scroll is changed means the Listbox items are not showing. So i put grid to show both. But that also not working. Any one knows please help me in this.

XML
<Style x:Key="mylists" TargetType="{x:Type ListBox}">
       <Setter Property="SnapsToDevicePixels" Value="true"/>
       <Setter Property="OverridesDefaultStyle" Value="true"/>
       <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
       <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
       <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
       <Setter Property="MinWidth" Value="120"/>
       <Setter Property="MinHeight" Value="95"/>
           <Setter Property="Template">
           <Setter.Value>
               <ControlTemplate TargetType="{x:Type ListBox}">
                       <Border x:Name="bd" Background="White">
                       <ScrollViewer Margin="0" Focusable="false" >
                           <Grid>
                               <Grid.ColumnDefinitions>
                                   <ColumnDefinition Width="80*" />
                                   <ColumnDefinition Width="Auto" MinWidth="{TemplateBinding MinWidth}"/>
                               </Grid.ColumnDefinitions>
                               <StackPanel Margin="2" IsItemsHost="True">
                               </StackPanel>
                               <ScrollBar Orientation="Vertical" Margin="0,0" HorizontalAlignment="Right" Grid.Column="1">
                                   <ScrollBar.Template>
                                       <ControlTemplate>
                                           <Track x:Name="PART_Track">
                                               <Track.DecreaseRepeatButton>
                                                   <RepeatButton Background="{x:Null}"/>
                                               </Track.DecreaseRepeatButton>
                                               <Track.IncreaseRepeatButton>
                                                   <RepeatButton Background="{x:Null}" />
                                               </Track.IncreaseRepeatButton>
                                               <Track.Thumb>
                                                   <Thumb Background="Gray" />
                                               </Track.Thumb>
                                           </Track>
                                       </ControlTemplate>
                                   </ScrollBar.Template>
                               </ScrollBar>
                           </Grid>
                       </ScrollViewer>
                   </Border>
                   <ControlTemplate.Triggers>

                   <Trigger Property="IsGrouping" Value="true">
                       <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                   </Trigger>
                   </ControlTemplate.Triggers>
               </ControlTemplate>
           </Setter.Value>
       </Setter>
   </Style>
Posted

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