I need to create structure of `ContextMenu` in runtime, because existence of `MenuItem`'s of the menu is based on many factors. And I try add handler to `ContextMenuOpening` event this way:

XAML

```
<TreeView x:Name="ArticlesTreeView" Grid.Column="0" AllowDrop="True">
    <TreeView.ItemContainerStyle>
        <Style TargetType="{x:Type TreeViewItem}">
            <Setter Property="ContextMenuService.ShowOnDisabled" Value="True" />
            <Setter Property="ContextMenu">
                <Setter.Value>
                    <ContextMenu Opened="ContextMenu_OnOpened">
                        <MenuItem Header="First item"></MenuItem>
                    </ContextMenu>
                </Setter.Value>
            </Setter>
        </Style>
    </TreeView.ItemContainerStyle>
</TreeView>

```

This code throws `XamlParseException` on `<ContextMenu Opened="ContextMenu_OnOpened">` line. Can I solve issue in another way?

**UPD** I find that to me it is necessary not `ContextMenuOpening` and `Opened` event. I corrected upper code.