■ NavBarControl 클래스에서 그룹/항목 모양을 커스텀 처리하기 위해 스타일을 사용하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar" Width="800" Height="600" Title="그룹/항목 모양을 커스텀 처리하기 위해 스타일 사용하기" FontFamily="나눔고딕코딩" FontSize="16"> <Window.Resources> <Style x:Key="CommonGroupStyleKey"> <Setter Property="dxn:NavBarViewBase.LayoutSettings" Value="{dxn:NavBarLayoutSettings TextHorizontalAlignment=Right}" /> <Setter Property="Control.Foreground" Value="Yellow" /> <Setter Property="Control.FontWeight" Value="Bold" /> </Style> <Style x:Key="CommonItemStyleKey"> <Setter Property="dxn:NavBarViewBase.LayoutSettings" Value="{dxn:NavBarLayoutSettings TextHorizontalAlignment=Right}" /> <Setter Property="Control.Foreground" Value="Blue" /> </Style> <Style x:Key="IndividualGroupStyleKey"> <Setter Property="dxn:NavBarViewBase.LayoutSettings" Value="{dxn:NavBarLayoutSettings TextHorizontalAlignment=Center}" /> <Setter Property="Control.Foreground" Value="LightBlue" /> <Setter Property="Control.FontWeight" Value="Bold" /> <Setter Property="Control.FontStyle" Value="Italic" /> </Style> <Style x:Key="IndividualGroupItemStyleKey"> <Setter Property="dxn:NavBarViewBase.LayoutSettings" Value="{dxn:NavBarLayoutSettings TextHorizontalAlignment=Center}" /> <Setter Property="Control.Foreground" Value="Gray" /> <Setter Property="Control.FontStyle" Value="Italic" /> </Style> <Style x:Key="IndividualItemStyleKey"> <Setter Property="dxn:NavBarViewBase.LayoutSettings" Value="{dxn:NavBarLayoutSettings TextHorizontalAlignment=Left}" /> <Setter Property="Control.Foreground" Value="Black" /> <Setter Property="Control.FontWeight" Value="Bold" /> </Style> </Window.Resources> <DockPanel Margin="10"> <dxn:NavBarControl x:Name="navBarControl"> <dxn:NavBarControl.View> <dxn:ExplorerBarView GroupVisualStyle="{StaticResource CommonGroupStyleKey}" ItemVisualStyle="{StaticResource CommonItemStyleKey}" /> </dxn:NavBarControl.View> <dxn:NavBarControl.Groups> <dxn:NavBarGroup Header="Group1"> <dxn:NavBarItem>Item1</dxn:NavBarItem> </dxn:NavBarGroup> <dxn:NavBarGroup Header="Group2"> <dxn:NavBarItem>Item1</dxn:NavBarItem> <dxn:NavBarItem>Item2</dxn:NavBarItem> </dxn:NavBarGroup> <dxn:NavBarGroup VisualStyle="{StaticResource IndividualGroupStyleKey}" ItemVisualStyle="{StaticResource IndividualGroupItemStyleKey}" Header="Group3"> <dxn:NavBarItem>Item1</dxn:NavBarItem> <dxn:NavBarItem>Item2</dxn:NavBarItem> <dxn:NavBarItem VisualStyle="{StaticResource IndividualItemStyleKey}"> Item3 </dxn:NavBarItem> </dxn:NavBarGroup> </dxn:NavBarControl.Groups> </dxn:NavBarControl> </DockPanel> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
using System.Windows; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); } #endregion } } |