Tabs become unresponsive

Ribbon for WPF Forum

Posted 17 years ago by Ron Gramann
Avatar
I'm a new user of your Ribbon control (v 1.0.330.0) and am putting together my first project. I've followed your QuickStart tutorials and everything was working fine. I have a placeholder control where you have a RichTextBox control. And on the <ribbon:Tab Command="MyProject:ApplicationCommands.LoadMyUserControl" ...>

In code, this executes:

private void LoadMyUserControl_Execute(object sender, ExecutedRoutedEventArgs e)
{
placeholder.Content = null;
MyUserControl control = new MyUserControl();
placeholder.Content = control;
}

I have this setup for 5 tabs, each loading a different UserControl. So far, so good.

When I use the application the UserControls load as expected, then unpredictably the Tabs become unresponsive, no longer responding to mouse events. Also the ApplicationOptions button and the Exit button in the menu become disabled.

I have not nailed down the exact steps to reproduce this problem, but was wondering if anyone has experienced something similiar.

Thanks

Ron

(PS. BTW, Fantastic control, keep up the good work)

[Modified at 06/04/2007 05:17 PM]

Comments (11)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ron,

Sometimes the WPF command model, while a great thing, can cause frustrating issues if the routing isn't working correctly. That may cause buttons to be disabled. But I'm not sure what is happening in this case since tabs and the app button shouldn't be affected.

Is there any chance you could continue to try and make a small repro project and email that over with steps to recreate? We'll be happy to debug it and sort out what is wrong. Thanks!


Actipro Software Support

Posted 17 years ago by Ron Gramann
Avatar
Will do.

Thanks for the quick response.

Cheers

Ron
Posted 17 years ago by Mario Matriccino
Avatar
I have the same exact issue. The Tabs become enabled again when I set focus to something in my user control. Did you ever find a workaround for this?
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mario,

I don't believe we ever heard more from Ron on this. If you would like our help, please send over a simple sample project that shows it happening.

Most likely, it is just something with core WPF command behavior and not a bug with our control. But we can have a look anyhow at a sample you provide.


Actipro Software Support

Posted 17 years ago by Francesco De Vittori
Avatar
I'm not sure if the problem mentioned is that the tabs themselves deactivate, or that buttons inside tabs become disabled (even if the CanExecute tells them to be enabled).

If it's the second case, I also had this problem and found that it happened because my buttons had no CommandTarget specified.
For example:

<ribbon:Button Command="local:WorkspaceCommands.NewScreen" />
This did the trick:

<UserControl x:Name="ThisControl" DataContext="{Binding ElementName=ThisControl}">
...
<ribbon:Button Command="local:WorkspaceCommands.NewScreen" CommandTarget="{Binding}" />
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The tabs themselves aren't tied to commands so they should always be enabled.

But in relation to buttons on tab groups... commands, while very nice overall, can be tricky sometimes. Because you need to ensure that focus is kept within a container that handles the command in order for it to be recognized as enabled. If focus leaves that container, then the commands on the ribbon might disable.

But like we posted, if anyone runs into problems getting commanded buttons working, make a simple sample project and send it over and perhaps we can point out what is wrong.


Actipro Software Support

Posted 16 years ago by Ron Gramann
Avatar
Sorry for my absence from this forum...

This issue seems to have risen again. I'm currently working on a Composite Application using the new P & P Composite Application Library (formerly known as Prism). I have managed to create a Shell application and each of my application modules add a RibbonTab through a service. All this works fine and is quite impressive.

However, on one of my tab detail I have a TreeView and ListView separated by a GridSplitter. When I resize using the GridSplitter, all the RibbonTabs go disabled. This is regardless of any CanExecute value. Strangely, all the Ribbon Buttons and ApplicationMenu are fine, it's just the RibbonTab that goes disabled.

This behaviour could be that focus is being captured by another module (WPF UserControl Library). If this is the case, do you know of a workaround? I have tried the CommandTarge={Binding} fix mentioned in this post, no joy.

Here is how the command is wired up:

<ribbon:Tab x:Key="RibbonTab"
Label="Directory"
Command="{x:Static cmd:RibbonCommands.LoadDirectory}"
CommandTarget="{Binding}">

...

private void BindCommands()
{
ribbonView.CommandBindings.Add(new CommandBinding(RibbonCommands.LoadDirectory, LoadDirectoryExecute, LoadDirectoryCanExecute));
}

private void LoadDirectoryCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}

private void LoadDirectoryExecute(object sender, ExecutedRoutedEventArgs e)
{
//show and hide user control in the main detail area
}


ActiPro Ribbon ver 3.5.420.0
Vista SP1
Visual Studio 2008

Any help or assistance is appreciated.

Cheers

Ron
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ron,

We don't set commands ourselves on the Tabs and there isn't anything that is in our code to disable tabs from what I recall. So I think it is the command that you are assigning to the Tab that is doing it. Especially since you said nothing else is affected except the Tabs.

For some reason the keyboard focus is probably moved outside of your control hierarchy that handles the command. Therefore, either the command CanExecute is not being handled or is returning false. But my guess is the former from what you posted. Really that is the only thing I can think of that would make your Tabs disable.

What happens when you click back in the content of your window again, do the Tabs enable?


Actipro Software Support

Posted 16 years ago by Ron Gramann
Avatar
It's definitely an issue with the focus. I have another UserControl that has a TextBox on it, and as soon as it gets focus, the RibbonTabs go disabled. The RibbonTabs never become enabled regardless if the Ribbon gets focus again.

I have also tried creating the CommandBinding without the CanExecuteRoutedEventHandler parameter, which should cause the command to be always enabled. But, this has no effect.

For architectural reasons, I'm trying to avoid wiring up event handlers on the Ribbon, but I may have to if no workaround is available.

Will post my findings.

Thanks for your help.

Ron
Posted 16 years ago by Ron Gramann
Avatar
Ok, I have removed the Command binding on the RibbonTab and have opted for working off the SelectTabChanged event on the Ribbon control and the disabled tabs behaviour has stopped.

Ron
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ron,

Yes WPF command routing can be a tricky thing sometimes to get working correctly. I had another idea for you though, what if you set FocusManager.IsFocusScope="True" on your UserControl. That would keep the main content of your Window still within the "main" focus scope while making your other part considered more like a menu with temporary focus scoping.

Anyhow, glad you got it working without commands.


Actipro Software Support

The latest build of this product (v24.1.3) was released 27 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.