How do I (can I?) set the ContextMenu of a AdvancedTabControlItem?

Docking/MDI for WPF Forum

Posted 7 years ago by Magnum White
Version: 16.1.0636
Avatar

How do I (can I?) set the ContextMenu of a AdvancedTabControlItem?

Following on from my other post I have been looking into being able to right click to bring up a ContextMenu.

Now I can see my ContextMenu is there in Snoop but Right Clicking does not give the expected result? 

I can assign it to the AdvancedTabControl but it then shows the ContextMenu where ever I right click except the tab items!

I am guessing I've missed something obvious here, but looking through the example app I couldn't find anything that would help. The "Custom Context Menu" looked helpfull but using the "MenuOpening" I got a null object...

<UserControl>
    <UserControl.Resources>

        <ContextMenu x:Key="MyContextMenu">
            <MenuItem Command="{Binding RemoveCommand}"
                      CommandParameter="{Binding}"
                      Header="Remove" />
        </ContextMenu>

        <Style TargetType="{x:Type docking:AdvancedTabItem}" x:Key="MyTabStyle">
            <Setter Property="Background" Value="Orange"/>
            <Setter Property="ContextMenu" Value="{StaticResource MyContextMenu}"/>
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate >
                        <TextBlock Text="{Binding Name}" FontSize="22" Background="HotPink" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid>
        <docking:AdvancedTabControl CanTabsDrag="True" 
                                    ItemContainerStyle="{StaticResource MyTabStyle}" 
                                    ItemsSource="{Binding Groups}" 
                                    SelectedItem="{Binding SelectedGroup}" />
    </Grid>
</UserControl>

[Modified 7 years ago]

Comments (4)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Magnum,

Right now it looks like it's not pulling in a ContextMenu assigned to the AdvancedTabItem.ContextMenu property.  We will add that for the 2017.1 version.  Note that your x:Key is on the wrong element in the sample code above too.

But the AdvancedTabControl.MenuOpening event does fire whenever a menu could be shown.  Just set the e.Menu to any ContextMenu you want to show there.

[Modified 7 years ago]


Actipro Software Support

Posted 7 years ago by Magnum White
Avatar

Thank you for the fast reply! What is the timeline for 2017.1?

Good spot on the x:Key, this example is just a simplification of what I've been working on.

I've also noticed that CanTabsDrag="True" does not seem to work on when using an ItemsSource. You can select it, and drag it but when you release it goes back to its original position. This is different behaviour from what I was expecting based off how the AdvancedTabControl works when you have hard coded AdvancedTabItems. Is there a step that I've missed?

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We just released v2017.1, so it's out now.

For the tab dragging, can you put together a new simple sample project that shows the issue and email that to our support address?  Then we'll use that to debug with and make any appropriate code changes.  Please rename the .zip file extension of what you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 7 years ago by Magnum White
Avatar

The ContextMenu works with v2017.1 which is great! 

The issue regarding the tab dragging was my own fault. I was binding to a List but if change that to an ObservableCollection then it works as expected.

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.