첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.04MB

▶ MainApplication.xaml

<Application x:Class="TestProject.MainApplication"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <materialDesign:BundledTheme
                    BaseTheme="Inherit"
                    PrimaryColor="DeepPurple"
                    SecondaryColor="Lime"
                    ColorAdjustment="{materialDesign:ColorAdjustment}" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

 

728x90

 

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    Width="800"
    Height="600"
    Title="Chip 엘리먼트 : 액션 칩 사용하기"
    Background="{DynamicResource MaterialDesignPaper}"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <Style TargetType="materialDesign:Chip">
            <Setter Property="Margin" Value="10" />
        </Style>
    </Window.Resources>
    <Grid>
        <StackPanel
            HorizontalAlignment="Center"
            VerticalAlignment="Center">
            <StackPanel Orientation="Horizontal">
                <materialDesign:Chip
                    Content="James Willock">
                    <materialDesign:Chip.Icon>
                        <Image Source="IMAGE/sample.jpg" />
                    </materialDesign:Chip.Icon>
                </materialDesign:Chip>
                <materialDesign:Chip Content="Example Chip"      />
                <materialDesign:Chip Content="ANZ Bank" Icon="A" />
                <materialDesign:Chip Content="ZNA Inc"  Icon="Z" />
                <materialDesign:Chip
                    IconBackground="{DynamicResource PrimaryHueDarkBrush}"
                    IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
                    Content="Twitter">
                    <materialDesign:Chip.Icon>
                        <materialDesign:PackIcon Kind="Twitter" />
                    </materialDesign:Chip.Icon>
                </materialDesign:Chip>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <materialDesign:Chip
                    IsDeletable="True"
                    ToolTip="Just a tool tip"
                    DeleteToolTip="Your friendly neighbor delete button"
                    Content="James Willock"
                    Click="chip_Click"
                    DeleteClick="chip_DeleteClick">
                    <materialDesign:Chip.Icon>
                        <Image Source="IMAGE/sample.jpg" />
                    </materialDesign:Chip.Icon>
                </materialDesign:Chip>
                <materialDesign:Chip
                    IsDeletable="True"
                    ToolTip="This is an example chip"
                    Content="Example Chip" />
                <materialDesign:Chip
                    Icon="A"
                    IsDeletable="True"
                    Content="ANZ Bank" />
                <materialDesign:Chip
                    IconBackground="{DynamicResource PrimaryHueLightBrush}"
                    IconForeground="{DynamicResource PrimaryHueLightForegroundBrush}"
                    Icon="Z" 
                    IsDeletable="True"
                    Content="ZNA Inc" />
            </StackPanel>
        </StackPanel>
    </Grid>
</Window>

 

300x250

 

▶ MainWindow.xaml.cs

using System.Windows;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 칩 클릭시 처리하기 - chip_Click(sender, e)

        /// <summary>
        /// 칩 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void chip_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Chip Clicked!");
        }

        #endregion
        #region 칩 삭제 버튼 클릭시 처리하기 - chip_DeleteClick(sender, e)

        /// <summary>
        /// 칩 삭제 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void chip_DeleteClick(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Chip delete button Clicked!");
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요