NavigationBar BindingExpression Errors

Navigation for WPF Forum

Posted 10 years ago by Arthur Damen
Version: 9.1.0505
Platform: .NET 3.5
Environment: Windows Vista (64-bit)
Avatar
Hi,

I'm getting the following errors when running an application with a NavigationBar.
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=ToolTip; DataItem='Button' (Name='toggleMinimizationButton'); target element is 'Button' (Name='toggleMinimizationButton'); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=ToolTip; DataItem='NavigationBarMinimizedPopupToggleButton' (Name='PART_ContentArea'); target element is 'NavigationBarMinimizedPopupToggleButton' (Name='PART_ContentArea'); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=ToolTip; DataItem='Button' (Name='toggleMinimizationButton'); target element is 'Button' (Name='toggleMinimizationButton'); target property is 'Name' (type 'String')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.Navigation.NavigationBar', AncestorLevel='1''. BindingExpression:Path=Title; DataItem=null; target element is 'Button' (Name='toggleMinimizationButton'); target property is 'ToolTip' (type 'Object')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=ToolTip; DataItem='Button' (Name='toggleMinimizationButton'); target element is 'Button' (Name='toggleMinimizationButton'); target property is 'Name' (type 'String')
The errors can simply be reproduced by running the following xaml code and minimizing the Navigation Bar. There isn't an exception thrown, but the errors should appear in the error output window.
<Window x:Class="Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:navigation="http://schemas.actiprosoftware.com/winfx/xaml/navigation"
  Title="Window1" Height="300" Width="300">
  <navigation:NavigationBar>

  </navigation:NavigationBar>
</Window>
Also the actipro sample projects generates these errors and they even appear to be interfering with the commandbindings of a ribbonwindow, because when the navigationbar is used in combination with the ribbonbar, that uses ribboncommands that binds on window level, all commands are disabled.
When the commandbinding takes place in the ribbonbar, the commands aren't affected.

Is there a workaround for this problem?

Kind regards,

Comments (5)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Arthur,

We took a look at the code and were able to eliminate all but one of the binding errors. The one we can't just seems to be a timing issue with the trigger in the style since its resulting binding (updating the tooltip text of the minimize button when collapsed) is working fine at run-time and we see the correct result. The updates will be in the next build.

Any time you have issues with ribbon or toolbar buttons that are command-driven being disabled, it generally has to do with focus. Focus must be within the visuals that contain the command bindings. If focus is in your NavBar when you minimize it, it could be that WPF is moving focus up to the root Window and above where the bindings can see. Therefore maybe on NavBar minimization (add an event handler), ensure that focus stays in your content area and it should fix the problem.


Actipro Software Support

Posted 10 years ago by Arthur Damen
Avatar
Hi,

Thanks for your quick response.

But how would I implement that the focus would stay on the content area? Because I tried some different scerario's of resetting the focus to an object or reëvaluating the commands but for some strange reason the ribbonbar buttons stay disabled.

Here is the code of project that I'm using, to try to solve this problem.
<Window x:Class="Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
  xmlns:navigation="http://schemas.actiprosoftware.com/winfx/xaml/navigation"
  xmlns:local="clr-namespace:WpfApplication4"
  Title="Window1" Height="450" Width="450">
  
  <Window.CommandBindings>
    <CommandBinding Command="{x:Static local:Window1.DoSomething}" CanExecute="CommandCanAlwaysExecute" Executed="CommandNotYetImplemented" />
  </Window.CommandBindings>
  
  <DockPanel>
    <ribbon:Ribbon DockPanel.Dock="Top">
      <ribbon:Tab Label="Home">
        <ribbon:Group Label="Something">
          <ribbon:Button Command="{x:Static local:Window1.DoSomething}"/>
        </ribbon:Group>
      </ribbon:Tab>
    </ribbon:Ribbon>
    
    <navigation:NavigationBar DockPanel.Dock="Left" ContentWidth="100">
      
    </navigation:NavigationBar>
    
    <Grid>
      <Button Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center" />
    </Grid>
  </DockPanel>
  
</Window>
Imports ActiproSoftware.Windows.Controls.Ribbon.Input

Partial Class Window1

  Public Shared ReadOnly DoSomething As New RibbonCommand("CmdDoSomething", GetType(Window1), "DoSomething")

  Private Sub CommandCanAlwaysExecute(ByVal sender As System.Object, ByVal e As System.Windows.Input.CanExecuteRoutedEventArgs)
    e.CanExecute = True
  End Sub

  Private Sub CommandNotYetImplemented(ByVal sender As System.Object, ByVal e As System.Windows.Input.ExecutedRoutedEventArgs)
    MessageBox.Show("Not yet implemented.", "TO DO", MessageBoxButton.OK, MessageBoxImage.Information)
  End Sub

End Class
And when you run this application and minimize(or maximize) the navigationbar the ribbonbar button gets disabled. It also occurs when you use the "show fever/more buttons", but in this example i've haven't got a navigationpane so the buttons are disabled.

Kind regards,
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Arthur,

Thanks for the report. We've modified our toggle minimization button to not be Focusable. That prevents WPF from moving focus up above the Window when the NavBar's template changes due to the minimization toggle.

I added some NavigationPanes with focusable content and am having trouble reproducing the other scenario with show more/fewer buttons. Can you give an exact repro for that as well? Thanks!


Actipro Software Support

Posted 10 years ago by Arthur Damen
Avatar
Hi,

I did some more testing and it looks like it only occurs when a Navigation Pane has the focus. So I've added some Navigation Panes to the Navigation Bar of the code in my last post.
    <navigation:NavigationBar DockPanel.Dock="Left" ContentWidth="100">
      <navigation:NavigationPane Header="Pane 1" />
      <navigation:NavigationPane Header="Pane 2" />
    </navigation:NavigationBar>
Then when you first select one the the panes and the select the show fever/more button. the ribbon bar button should disable.

Kind regards,
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Arthur,

Thanks we fixed this for the next build too.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.