![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | jumping ListBox Hi! I have a little problem creating a custom ListBox in Dec-CTP. To see the problem, just paste the code below into XamlPad. Problem: Everytime you select an item at the bottom of the ListBox, the ScrollViewer jumps almost to the top ![]() Setting CanContentScroll="true" in the Template solves the Problem, but creates other problems in my application, so this solution doesn't help me at all ![]() Any tips from you guys how to solve this problem? Michael <Grid Name="root" xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"> <Grid.Resources> <Style x:Key="{x:Type ListBox}" TargetType="{x:Type ListBox}"> <Setter Property="DefaultStyleKey" Value="{x:Null}" /> <Setter Property="Background" Value="White" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderBrush" Value="#aa000000" /> <Setter Property="Padding" Value="2" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}"> <Border CornerRadius="4" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" > <ScrollViewer CanContentScroll="false" Margin="1" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" Padding="{TemplateBinding Padding}" > <ItemsPresenter/> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Background" Value="#EEEEEE" /> </Trigger> </Style.Triggers> </Style> <Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}"> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border CornerRadius="3" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"> <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" HorizontalAlignment="Stretch" Name="ContentSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="#eeF5F5FF" /> <Setter Property="BorderBrush" Value="Silver" /> <Setter Property="Foreground" Value="Black" /> </Trigger> </Style.Triggers> </Style> </Grid.Resources> <ListBox HorizontalAlignment="Center" Height="150"> <ListBoxItem>Test1</ListBoxItem> <ListBoxItem>Test2</ListBoxItem> <ListBoxItem>Test3</ListBoxItem> <ListBoxItem>Test4</ListBoxItem> <ListBoxItem>Test5</ListBoxItem> <ListBoxItem>Test6</ListBoxItem> <ListBoxItem>Test7</ListBoxItem> <ListBoxItem>Test1</ListBoxItem> <ListBoxItem>Test2</ListBoxItem> <ListBoxItem>Test3</ListBoxItem> <ListBoxItem>Test4</ListBoxItem> <ListBoxItem>Test5</ListBoxItem> <ListBoxItem>Test6</ListBoxItem> <ListBoxItem>Test7</ListBoxItem> <ListBoxItem>Test1</ListBoxItem> <ListBoxItem>Test2</ListBoxItem> <ListBoxItem>Test3</ListBoxItem> <ListBoxItem>Test4</ListBoxItem> <ListBoxItem>Test5</ListBoxItem> <ListBoxItem>Test6</ListBoxItem> <ListBoxItem>Test7</ListBoxItem> <ListBoxItem>Test1</ListBoxItem> <ListBoxItem>Test2</ListBoxItem> <ListBoxItem>Test3</ListBoxItem> <ListBoxItem>Test4</ListBoxItem> <ListBoxItem>Test5</ListBoxItem> <ListBoxItem>Test6</ListBoxItem> <ListBoxItem>Test7</ListBoxItem> </ListBox> </Grid> |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Set Listbox Value | .NET General | |||
| Easy to get handle from listbox. How to get listbox from handle? | .NET General | |||
| Listbox | PowerShell | |||