Reputation: 1813
I'm trying to edit some code so that a context menu is contained in the resources of a xaml file rather than within the actual code. The context menu is:
<ContextMenu x:Key="CameraControlContextMenu" x:Shared="False" cal:Action.TargetWithoutContext="{Binding Path=DataContext, RelativeSource={RelativeSource Self}}">
<exclusiveMenuItem:ExclusiveMenuItem x:Name="Turn" Header="{DynamicResource SetCameraToTurn}" IsCheckable="True" IsChecked="{Binding IsTurnMode}" cal:Message.Attach="[Event Click] = [Action TurnMode]" IsEnabled="{Binding IsAvailable}" Icon="{DynamicResource TurningImageSource}"/>
<exclusiveMenuItem:ExclusiveMenuItem x:Name="Drag" Header="{DynamicResource SetCameraToDrag}" IsCheckable="True" IsChecked="{Binding IsDragMode}" cal:Message.Attach="[Event Click] = [Action DragMode]" Icon="{DynamicResource DragImageSource}"/>
</ContextMenu>
Anyway, the context menu works fine and was located within another menu:
<splitButton:SplitButton.DropDownContextMenu>
CONTEXTMENUWASHERE
</splitButton:SplitButton.DropDownContextMenu>
I'm trying to extract it into the XAML file's resources so I can use it in more than one place. I'm having a bit of trouble though. I've taken it out fine, the problem is referencing the context menu in the resources from within that splitbutton there.
My XAML is a little shaky and I'm finding this a bit tricky to research, although I imagine the solution is probably something very simple.
Any help is appreciated, thanks.
Upvotes: 0
Views: 99
Reputation: 69979
I don't really see your problem, or perhaps I've either misunderstood it, or you're just not seeing the wood for the trees? How about setting the ContextMenu
on your control in the normal short XAML form:
<splitButton:SplitButton
DropDownContextMenu="{StaticResource CameraControlContextMenu}" />
Upvotes: 1