본문 바로가기
C#/WPF

[RJ Code Advance EN] Login Form

by HJ0216 2024. 2. 9.

이 글은 [RJ Code Advance EN] 수강하며 정리한 글입니다.

 

👉 기본 환경

- Language: C#, xaml

- IDE: Visual Basic 2022

 


Solution: RJ_Code_Advance_EN

 

🫠영상과 다른 설정을 한 부분

1. 버튼 설정

<!-- 기존 -->
<Button
    Grid.Column="1"
    x:Name="buttonMinimize"
    Content="-"
    BorderThickness="0"
    Foreground="White"
    FontSize="16"
    Cursor="Hand"
    Click="buttonMinimize_Click"
    >
    <Button.Style>
        <Style TargetType="Button">
            <Setter
                Property="Background"
                Value="#28AEED"
                />
            <Style.Triggers>
                <Trigger
                    Property="IsMouseOver"
                    Value="True"
                    >
                    <Setter
                        Property="Background"
                        Value="#2788EF"
                        />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Button.Style>

    <Button.Template>
        <ControlTemplate>
            <Border
                Width="18" Height="18"
                CornerRadius="9"
                Background="{TemplateBinding Background}"
                >
                <ContentPresenter
                    VerticalAlignment="Top"
                    HorizontalAlignment="Center"
                    />
            </Border>
        </ControlTemplate>
    </Button.Template>
</Button>

 

<!-- 변경 -->
<Button
    Grid.Column="1"
    x:Name="buttonMinimize"
    BorderThickness="0"
    Foreground="White"
    FontSize="16"
    Cursor="Hand"
    Click="buttonMinimize_Click"
    >
    <Button.Style>
        <Style TargetType="Button">
            <Setter
                Property="Background"
                Value="#28AEED"
                />
            <Style.Triggers>
                <Trigger
                    Property="IsMouseOver"
                    Value="True"
                    >
                    <Setter
                        Property="Background"
                        Value="#2788EF"
                        />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Button.Style>

    <Button.Template>
        <ControlTemplate>
            <Border
                Width="18" Height="18"
                CornerRadius="9"
                Background="{TemplateBinding Background}"
                >
                <ContentPresenter
                    Content="-"
                    VerticalAlignment="Top"
                    HorizontalAlignment="Center"
                    />
            </Border>
        </ControlTemplate>
    </Button.Template>
</Button>

 

Button 태그의 Content 속성을 통해 내용 표시

🚨 Content가 표시되지 않는 문제 발생

    💡ControlTemplate을 통해 버튼 모양을 변경할 경우, Button의 Content 속성이 아닌 ContentPresenter의 Content 속성에서 표시

 

🚨 Image가 실행창에서 보이지 않는 문제 발생

    💡이미지를 새로 추가한 경우, 리소스 등록 및 재빌드 과정을 거쳐야 함

         이미지 우클릭 → 속성 → 빌드 작업: 리소스 → 재빌드

 

 

 

📚 참고 자료

 

[WPF]Image 가 보이지 않을 때 , 나타나지 않을 때

WPF 에서 이미지를 Resource 를 등록해서 나타나게 할 때 화면에 보이지 않는 경우가 있다. 대부분의 경우 리소스 등록과 빌드 설정으로 인해 나타나지 않는 경우가 대부분이다. - 먼저 우측 탐색기

gdpark.tistory.com