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

Check a checkbox with the space bar

Closed Thread
 
Thread Tools Display Modes
Old 03-31-2008   #1 (permalink)
RF
Guest


 

Check a checkbox with the space bar

Hi,

i have the following XAML and can't seem to figure out how to make the
checkbox react to the space bar.

<ListView Height="132" Margin="35,0,20,48" Name="m_listViewEvents"
VerticalAlignment="Bottom">
<ListView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=Items}">
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=IsSelected}"
Margin="1,1,4,1"/>
<TextBlock Text="{Binding Path=Text}"
Margin="1,1,4,1"/>
</StackPanel>
</HierarchicalDataTemplate>
</ListView.ItemTemplate>
</ListView>


Old 04-20-2008   #2 (permalink)
Motonari Ito
Guest


 

RE: Check a checkbox with the space bar

Hi,
Quote:

> i have the following XAML and can't seem to figure out how to make the
> checkbox react to the space bar.
I have the same problem - any help would be appreciated. The minimal
reproducible code is here:

<ListBox ItemsSource="{x:Static Fonts.SystemFontFamilies}">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox>
<TextBlock Text="{Binding Source}"/>
</CheckBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

As it turns out, a space bar does not work because key focus is not on a
check box but on ListBoxItem. If I hit [TAB] to move the focus to the check
box, then it works.

Keyboard operation is essential for my application. Please, please help me.

Thank you.

Old 05-26-2008   #3 (permalink)
Lemming
Guest


 

RE: Check a checkbox with the space bar

Hello,

Unfortunately, this simple looking scenario is not easy to solve, it's
actually pretty complicated because getting the elements defined inside a
DataTemplate is changes the behaviour of the ItemsControl (it adds an idea of
"checkability" to an ItemsControl which only support "selectability").

For your scenario, consider StackPanels or WrapPanels which would contain
CheckBoxes for each of your items. Something like the following:

<StackPanel KeyboardNavigation.DirectionalNavigation="Contained">
<CheckBox>One</CheckBox>
<CheckBox>Two</CheckBox>
<CheckBox>Three</CheckBox>
<CheckBox>Four</CheckBox>
</StackPanel>
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Welcome Center - can't get rid of it (checkbox is missing!) William Dowell Vista General 0 07-23-2008 10:42 AM
Checkbox in GridView Column Jay Avalon 1 01-08-2008 09:56 AM
Checkbox to never see this pop-up again. Andrew Garttmeyer Vista account administration 1 07-26-2007 04:56 AM
CheckBox groups Erno Avalon 2 02-05-2006 12:34 PM
No CheckBox.CheckedChanged? RyanLeeSchneider Avalon 6 01-31-2006 06:59 AM








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