|
1 |
| -<!-- default badges list --> |
2 |
| - |
3 |
| -[](https://supportcenter.devexpress.com/ticket/details/E3335) |
4 |
| -[](https://docs.devexpress.com/GeneralInformation/403183) |
5 |
| -[](#does-this-example-address-your-development-requirementsobjectives) |
6 |
| -<!-- default badges end --> |
7 |
| - |
8 |
| -# WPF Gauges - Create a volume knob |
9 |
| - |
10 |
| -This example customizes the [CircularGaugeControl](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CircularGaugeControl). As a result, the control looks and behaves like a 'knob' element of a real-life dashboard. |
11 |
| - |
12 |
| - |
13 |
| - |
14 |
| -## Implementation Details |
15 |
| - |
16 |
| -The **KnobResourceDictionary.xaml** file contains the following custom templates: |
17 |
| - |
18 |
| -* The **OscilloscopeNeedleTemplate** changes the arc scale's [needle](https://docs.devexpress.com/WPF/9957/controls-and-libraries/gauge-controls/visual-elements/circular-gauge/needle) appearance. |
19 |
| -* The **OscilloscopeScaleLayerTemplate** changes the arc scale's [layer](https://docs.devexpress.com/WPF/9962/controls-and-libraries/gauge-controls/visual-elements/circular-gauge/layers) appearance. |
20 |
| - |
21 |
| -Set the needle's [IsInteractive](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.ValueIndicatorBase.IsInteractive) property to `true` to allow users to change the gauge's value. The gauge stores its value in the needle's `Value` property. |
22 |
| - |
23 |
| -## Files to Review |
24 |
| - |
25 |
| -* [KnobResourceDictionary.xaml](./CS/DXGauges_Knobs/KnobResourceDictionary.xaml) (VB: [KnobResourceDictionary.xaml](./VB/DXGauges_Knobs/KnobResourceDictionary.xaml)) |
26 |
| -* [MainWindow.xaml](./CS/DXGauges_Knobs/MainWindow.xaml) (VB: [MainWindow.xaml](./VB/DXGauges_Knobs/MainWindow.xaml)) |
27 |
| - |
28 |
| -## Documentation |
29 |
| - |
30 |
| -* [CircularGaugeControl](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CircularGaugeControl) |
31 |
| -* [Circular Gauge Elements](https://docs.devexpress.com/WPF/9954/controls-and-libraries/gauge-controls/visual-elements/circular-gauge) |
32 |
| -<!-- feedback --> |
| 1 | +<!-- default badges list --> |
| 2 | + |
| 3 | +[](https://supportcenter.devexpress.com/ticket/details/E3335) |
| 4 | +[](https://docs.devexpress.com/GeneralInformation/403183) |
| 5 | +[](#does-this-example-address-your-development-requirementsobjectives) |
| 6 | +<!-- default badges end --> |
| 7 | + |
| 8 | +# WPF Gauges – Create a Volume Knob |
| 9 | + |
| 10 | +This example changes the [`CircularGaugeControl`](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CircularGaugeControl) so that it looks and behaves like a volume knob. Turn the gauge needle to update the percentage label under the control. |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +Use the `CircularGaugeControl` when you need to: |
| 15 | + |
| 16 | +* Create an interactive rotary control to adjust a value. |
| 17 | +* Imitate analog controls in dashboards, audio mixers, or monitoring panels. |
| 18 | +* Apply a custom design to match a specific UI theme. |
| 19 | + |
| 20 | +## Implementation Details |
| 21 | + |
| 22 | +### Custom Needle and Scale Templates |
| 23 | + |
| 24 | +Define custom templates in the [KnobResourceDictionary.xaml](./CS/DXGauges_Knobs/KnobResourceDictionary.xaml) file: |
| 25 | + |
| 26 | +* `OscilloscopeNeedleTemplate` – changes the needle shape and color. |
| 27 | +* `OscilloscopeScaleLayerTemplate` – changes the gauge background and decorative elements. |
| 28 | + |
| 29 | +The following code example applies templates through [`CustomArcScaleNeedlePresentation`](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CustomArcScaleNeedlePresentation) and [`CustomArcScaleLayerPresentation`](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CustomArcScaleLayerPresentation) properties: |
| 30 | + |
| 31 | +```xaml |
| 32 | +<dxga:ArcScaleNeedle.Presentation> |
| 33 | + <dxga:CustomArcScaleNeedlePresentation |
| 34 | + NeedleTemplate="{StaticResource OscilloscopeNeedleTemplate}" /> |
| 35 | +</dxga:ArcScaleNeedle.Presentation> |
| 36 | +... |
| 37 | +<dxga:ArcScaleLayer.Presentation> |
| 38 | + <dxga:CustomArcScaleLayerPresentation |
| 39 | + ScaleLayerTemplate="{StaticResource OscilloscopeScaleLayerTemplate}" /> |
| 40 | +</dxga:ArcScaleLayer.Presentation> |
| 41 | +``` |
| 42 | + |
| 43 | +### Gauge Configuration |
| 44 | + |
| 45 | +The circular gauge has the following features: |
| 46 | + |
| 47 | +* Starts at `0` and ends at `100`. |
| 48 | +* Uses a custom start/end angle to simulate knob rotation. |
| 49 | +* Hides numeric labels and displays only tick marks. |
| 50 | +* Supports interactive needle movement. |
| 51 | + |
| 52 | +```xaml |
| 53 | +<dxga:ArcScale |
| 54 | + StartValue="0" EndValue="100" |
| 55 | + StartAngle="-230" EndAngle="50" |
| 56 | + ShowLabels="False"> |
| 57 | +``` |
| 58 | + |
| 59 | +Use the `SmartTickmarksPresentation` property to change the tick mark style and position tick marks with negative offsets to align with the custom scale. |
| 60 | + |
| 61 | +### Value Display |
| 62 | + |
| 63 | +A `Label` displays the gauge value. Its content is bound to the needle’s `Value` property: |
| 64 | + |
| 65 | +```xaml |
| 66 | +<Label Content="{Binding ElementName=needle, Path=Value}" |
| 67 | + ContentStringFormat=" Volume: {0:f0} % " /> |
| 68 | +``` |
| 69 | + |
| 70 | +The label updates automatically when the knob is rotated. |
| 71 | + |
| 72 | +## Files to Review |
| 73 | + |
| 74 | +* [KnobResourceDictionary.xaml](./CS/DXGauges_Knobs/KnobResourceDictionary.xaml) (VB: [KnobResourceDictionary.xaml](./VB/DXGauges_Knobs/KnobResourceDictionary.xaml)) |
| 75 | +* [MainWindow.xaml](./CS/DXGauges_Knobs/MainWindow.xaml) (VB: [MainWindow.xaml](./VB/DXGauges_Knobs/MainWindow.xaml)) |
| 76 | + |
| 77 | +## Documentation |
| 78 | + |
| 79 | +* [CircularGaugeControl](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CircularGaugeControl) |
| 80 | +* [Circular Gauge Elements](https://docs.devexpress.com/WPF/9954/controls-and-libraries/gauge-controls/visual-elements/circular-gauge) |
| 81 | +* [CustomArcScaleLayerPresentation](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CustomArcScaleLayerPresentation) |
| 82 | +* [CustomArcScaleNeedlePresentation](https://docs.devexpress.com/WPF/DevExpress.Xpf.Gauges.CustomArcScaleNeedlePresentation) |
| 83 | +* [Gauge Controls](https://docs.devexpress.com/WPF/115093/controls-and-libraries/gauge-controls) |
| 84 | + |
| 85 | +## More Examples |
| 86 | + |
| 87 | +* [WPF Linear Gauge – Display Custom UI Elements](https://github.com/DevExpress-Examples/wpf-linear-gauge-display-custom-ui-elements) |
| 88 | +* [WPF Gauges Getting Started – Lesson 3 – Create a Digital Gauge](https://github.com/DevExpress-Examples/wpf-gauges-getting-started-create-digital-gauge) |
| 89 | +* [WPF Gauges – Set Width and Height of Symbols in Digital Gauge](https://github.com/DevExpress-Examples/wpf-gauges-set-width-and-height-of-symbols-in-digital-gauge-control) |
| 90 | +* [WPF Gauge – Create a Digital Gauge](https://github.com/DevExpress-Examples/wpf-create-digital-gauge) |
| 91 | +* [Reporting for WPF – Advanced Gauge Customization](https://github.com/DevExpress-Examples/reporting-wpf-advanced-gauge-customization) |
| 92 | + |
| 93 | +<!-- feedback --> |
33 | 94 | ## Does this example address your development requirements/objectives?
|
34 | 95 |
|
35 | 96 | [<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=wpf-gauges-create-volume-knob&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=wpf-gauges-create-volume-knob&~~~was_helpful=no)
|
36 | 97 |
|
37 |
| -(you will be redirected to DevExpress.com to submit your response) |
38 |
| -<!-- feedback end --> |
| 98 | +(you will be redirected to DevExpress.com to submit your response) |
| 99 | +<!-- feedback end --> |
0 commit comments