IsTabStop and ItemsControl

Topics: Bugs, Conventions
May 25, 2011 at 6:18 PM


I'm having some trouble tabbing through the elements in an Itemscontrol. I seem to stop at both the intended View and the ContentControl containing the View (according to FocusManager.GetFocusedElement()), so that I need to push Tab one time to many. The code looks like this:


	public ObservableCollection<FieldViewModel> Fields { getset; }

        public ShellViewModel()
            Fields = new ObservableCollection<FieldViewModel>();
            Fields.Add(new FieldViewModel());
            Fields.Add(new FieldViewModel());
            Fields.Add(new FieldViewModel());

    <Grid x:Name="LayoutRoot" Background="White">
        <ItemsControl x:Name="Fields" />


<UserControl x:Class="SilverlightApplication92.FieldView"
    d:DesignHeight="300" d:DesignWidth="400" 
    <Grid x:Name="LayoutRoot" Background="White">
        <Rectangle x:Name="myRectangle" Width="100" Height="100" Fill="Blue" Margin="5 5 5 5" />

FieldView.xaml.cs (Just for testing)

        public FieldView()

        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

        private void UserControl_GotFocus(object sender, RoutedEventArgs e)
            myRectangle.Fill = new SolidColorBrush(Colors.Red);

        private void UserControl_LostFocus(object sender, RoutedEventArgs e)
            myRectangle.Fill = new SolidColorBrush(Colors.Blue);

Anyone knows how to deal with this problem?


May 26, 2011 at 11:13 AM

I might add that this is readily fixed by modifying the Caliburn code:

In ConventionManager.cs line 42:
<ContentControl cal:View.Model=\"{Binding}\" VerticalContentAlignment=\"Stretch\" HorizontalContentAlignment=\"Stretch\" IsTabStop=\"False\" />

but I don't think this is the right way to go.

May 26, 2011 at 1:34 PM

Would there be any negative affects of me adding that? Does that prevent the controls inside the ContentControl from being tab stops?

May 26, 2011 at 2:07 PM

1. Hard to say but I don't think so. I've been running several Caliburn project with the modified code today and I havn't noticed any negative affects.

2. No. It only prevent the ContentControl. With the IsTabStop modification I'm able to tab through the ItemsControl with only one Tab per Item. 

May 26, 2011 at 2:11 PM

Ok. I may just add it then for the next release. Thanks!

May 26, 2011 at 2:44 PM

Cool man :) This is important for my project. Thanks!

May 26, 2011 at 3:12 PM

Fixed in Trunk.