Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

jumping ListBox

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
michael.talics@gmail.com
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51