![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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 | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mouse Jumping all over | Retsep | Vista Games | 6 | 07-07-2008 04:08 PM |
| Easy to get handle from listbox. How to get listbox from handle? | IMAFriend | .NET General | 0 | 03-27-2008 08:31 PM |
| Listbox | Anatoli | PowerShell | 7 | 12-04-2007 04:24 AM |
| Re: Jumping cursor | Tom Brown | Vista mail | 0 | 03-12-2007 11:02 PM |
| ListBox SelectionChangedEvent | PT | Avalon | 1 | 04-02-2006 07:38 PM |