Control Context Menu Display

Jul 15, 2011 at 6:07 PM

I have a WPF control with a context menu that works fine except that it seems that the Fluent:Window overrides the behavior and is not handing the events to the contained control. Here is a simple example that reproduces the behavior I see. If this is a normal <Window/> rather than a <Fluent:Window/> the control behaves as expected, however, when wrapped in a <Fluent:Window/> the control context menus are never show. Is there a way to get these to respond when using the Fluent:Window? I think I am missing something here.

See samples below:

No Context Menu:

<Fluent:RibbonWindow  x:Class="TestRealVar.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
        Title="MainWindow" Height="350" Width="525"                     >
<Fluent:RibbonWindow.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Fluent:RibbonWindow.Resources>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <TextBox Height="30" Width="300"  Name="ValueBox"  AutoWordSelection="True" Background="White" 
                 Focusable="True"  BorderBrush="Blue" HorizontalContentAlignment="Right" Margin="93,101,110,180">
      <TextBox.ContextMenu>
        <ContextMenu x:Name="contextMenuStripConvert" Opened="DoNothing">
          <MenuItem x:Name="convertToolStripMenuItem" Header="Convert">
            <MenuItem x:Name="UnitConversionToolStripMenuItem" Header="none"></MenuItem>
          </MenuItem>
          <Separator ></Separator>
          <MenuItem x:Name="copyToolStripMenuItem" Header="_Copy" Click="DoNothing">
          </MenuItem>
          <MenuItem x:Name="copyValueStripMenuItem" Header="Copy Value">
            <MenuItem.IsEnabled>False</MenuItem.IsEnabled>
          </MenuItem>
          <MenuItem x:Name="pasteToolStripMenuItem" Header="Paste" Click="DoNothing">
          </MenuItem>
          <MenuItem x:Name="clearToolStripMenuItem" Header="Clear Contents" Click="DoNothing">
          </MenuItem>
        </ContextMenu>
      </TextBox.ContextMenu>
    </TextBox>
  </Grid>
</Fluent:RibbonWindow>
 
Context Menu Works:
<Window  x:Class="TestRealVar.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
        Title="MainWindow" Height="350" Width="525"                     >
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <TextBox Height="30" Width="300"  Name="ValueBox"  AutoWordSelection="True" Background="White" 
                 Focusable="True"  BorderBrush="Blue" HorizontalContentAlignment="Right" Margin="93,101,110,180">
      <TextBox.ContextMenu>
        <ContextMenu x:Name="contextMenuStripConvert" Opened="DoNothing">
          <MenuItem x:Name="convertToolStripMenuItem" Header="Convert">
            <MenuItem x:Name="UnitConversionToolStripMenuItem" Header="none"></MenuItem>
          </MenuItem>
          <Separator ></Separator>
          <MenuItem x:Name="copyToolStripMenuItem" Header="_Copy" Click="DoNothing">
          </MenuItem>
          <MenuItem x:Name="copyValueStripMenuItem" Header="Copy Value">
            <MenuItem.IsEnabled>False</MenuItem.IsEnabled>
          </MenuItem>
          <MenuItem x:Name="pasteToolStripMenuItem" Header="Paste" Click="DoNothing">
          </MenuItem>
          <MenuItem x:Name="clearToolStripMenuItem" Header="Clear Contents" Click="DoNothing">
          </MenuItem>
        </ContextMenu>
      </TextBox.ContextMenu>
    </TextBox>
  </Grid>
</Window>