|
3 | 3 | [](https://supportcenter.devexpress.com/ticket/details/T325071)
|
4 | 4 | [](https://docs.devexpress.com/GeneralInformation/403183)
|
5 | 5 | <!-- default badges end -->
|
6 | | -<!-- default file list --> |
7 | | -*Files to look at*: |
8 | 6 |
|
9 | | -* [MainWindow.xaml](./CS/RadialMenuExample/MainWindow.xaml) (VB: [MainWindow.xaml](./VB/RadialMenuExample/MainWindow.xaml)) |
10 | | -* [MainWindow.xaml.cs](./CS/RadialMenuExample/MainWindow.xaml.cs) (VB: [MainWindow.xaml.vb](./VB/RadialMenuExample/MainWindow.xaml.vb)) |
11 | | -* [TextBoxService.cs](./CS/RadialMenuExample/TextBoxService.cs) (VB: [TextBoxService.vb](./VB/RadialMenuExample/TextBoxService.vb)) |
12 | | -* [ViewModel.cs](./CS/RadialMenuExample/ViewModel.cs) (VB: [ViewModel.vb](./VB/RadialMenuExample/ViewModel.vb)) |
13 | | -<!-- default file list end --> |
14 | | -# How to: Create a Radial Context Menu |
| 7 | +# Create a Radial Context Menu for WPF |
| 8 | + |
| 9 | +This example demonstrates how to create a [WPF Radial Context Menu](https://docs.devexpress.com/WPF/DevExpress.Xpf.Bars.RadialContextMenu) and assign it to a text box. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Implementation Details |
15 | 14 |
|
| 15 | +The radial menu's DataContext is bound to the window's DataContext. The DataContext is set to a `RadialContextMenuViewModel` object (it is automatically generated by `DevExpress.Mvvm.POCO.ViewModelSource`). This object automatically generates commands for all public methods in the `RadialContextMenuViewModel` class. |
16 | 16 |
|
17 | | -<p>This example shows how to assign a <a href="https://documentation.devexpress.com/WPF/clsDevExpressXpfBarsRadialContextMenutopic.aspx">RadialContextMenu</a> to a text box and initialize the menu with items.</p> |
18 | | -<p>To assign the <a href="https://documentation.devexpress.com/WPF/clsDevExpressXpfBarsRadialContextMenutopic.aspx">RadialContextMenu</a> to the text box, the <a href="https://documentation.devexpress.com/WPF/DevExpressXpfBarsBarManager_DXContextMenutopic.aspx">BarManager.DXContextMenu</a> attached property is used.</p> |
19 | | -The radial menu displays three regular buttons (Copy, Cut and Paste) and one sub-menu (Select All) that provides access to two additional items (Clear and Select All). Commands are assigned to the buttons with the Command properties.<br><img src="https://raw.githubusercontent.com/DevExpress-Examples/how-to-create-a-radial-context-menu-t325071/14.2.4+/media/d84f3cf7-a3d1-11e5-80bf-00155d62480c.png"><br>The radial menu's DataContext is bound to the window's DataContext. This DataContext is set to a RadialContextMenuViewModel class descendant, which is automatically generated by the <strong>DevExpress.Mvvm.POCO.ViewModelSource</strong> object. This descendant automatically generates commands for all public methods in the RadialContextMenuViewModel class (the ClearSelectionCommand is generated for the ClearSelection method). |
| 17 | +The radial menu displays four items: "Copy", "Cut", "Paste", and "Select All". The "Select All" item is a sub-menu with "Clear" and "Select All" items. |
20 | 18 |
|
21 | | -<br/> |
| 19 | +The item's [Command](https://docs.devexpress.com/WPF/DevExpress.Xpf.Bars.BarItem.Command) property specifies the command: |
22 | 20 |
|
| 21 | +```xaml |
| 22 | +<dxb:BarButtonItem Content="Copy" Glyph="{dx:DXImage Image=Copy_16x16.png}" Command="{Binding CopyCommand}" CommandTarget="{Binding}" /> |
| 23 | +``` |
23 | 24 |
|
| 25 | +Use the the [BarManager.DXContextMenu](https://docs.devexpress.com/WPF/DevExpress.Xpf.Bars.BarManager.DXContextMenu) property to assign the radial context menu to the text box. |
| 26 | + |
| 27 | + |
| 28 | +## Files to Review |
| 29 | + |
| 30 | +* [MainWindow.xaml](./CS/RadialMenuExample/MainWindow.xaml) (VB: [MainWindow.xaml](./VB/RadialMenuExample/MainWindow.xaml)) |
| 31 | +* [TextBoxService.cs](./CS/RadialMenuExample/TextBoxService.cs) (VB: [TextBoxService.vb](./VB/RadialMenuExample/TextBoxService.vb)) |
| 32 | +* [ViewModel.cs](./CS/RadialMenuExample/ViewModel.cs) (VB: [ViewModel.vb](./VB/RadialMenuExample/ViewModel.vb)) |
0 commit comments