[WPF] Flat Button

C#/WPF 2020. 12. 1. 09:12
728x90
728x170
<Window x:Class="WpfAppControlTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfAppControlTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.Resources>
        <Style x:Key="Flat">
            <Setter Property="Control.Background" Value="{x:Null}" />
            <!--<Setter Property="Control.BorderBrush" Value="{x:Null}" />-->
            <Style.Triggers>
                <Trigger Property="Control.IsMouseOver" Value="True">
                    <Setter Property="Control.Background" Value="{x:Null}" />
                    <!--<Setter Property="Control.BorderBrush" Value="{x:Null}" />-->
                    <Setter Property="Control.FontWeight" Value="Bold" />
                </Trigger>
                <Trigger Property="Control.IsFocused" Value="True">
                    <Setter Property="Control.FontWeight" Value="Bold" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <StackPanel>
        <Button Style="{StaticResource Flat}" Width="100">Hello</Button>
    </StackPanel>
</Window>

테두리도 보기 싫다면 주석 되있는 내용을 주석처리를 풀면된다.

 

728x90
그리드형
Posted by kjun
,