티스토리 뷰

C#/WPF

WPF tutorial - Control ToolTips

광그로 2017. 6. 22. 15:45

http://www.wpf-tutorial.com/control-concepts/tooltips/


Control ToolTips은 특정 컨트롤이나 링크에 마우스를 올려놓음으로써 추가정보를 얻을 수 있는 기능입니다.


1
2
3
4
5
6
7
<StackPanel Margin="10">
        <Label>Text:</Label>
        <TextBox />
        <Label>Password:</Label>
        <PasswordBox MaxLength="6" PasswordChar="*" ToolTip ="비밀번호를 볼 수 없습니다.">
        </PasswordBox>
    </StackPanel>
cs



WPF에서의 Tooltip 속성은 string 타입이 아닌 object 타입입니다. 이것은 우리가 원하는 모든 것을 넣을 수 있음을 의미합니다.

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
    <DockPanel>
        <ToolBar DockPanel.Dock="Top">
            <Button ToolTip="Create a new file">
                <Button.Content>
                    <Image Source="https://freeiconshop.com/wp-content/uploads/edd/document-add-outline.png" Width="16" Height="16" />
                </Button.Content>
            </Button>
            <Button>
                <Button.Content>
                    <Image Source="https://freeiconshop.com/wp-content/uploads/edd/folder-open-outline-filled.png" Width="16" Height="16" />
                </Button.Content>
                <Button.ToolTip>
                    <StackPanel>
                        <TextBlock FontWeight="Bold" FontSize="14" Margin="0,0,0,5">Open file</TextBlock>
                        <TextBlock>
                        Search your computer or local network
                        <LineBreak />
                        for a file and open it for editing.
                        </TextBlock>
                        <Border BorderBrush="Silver" BorderThickness="0,1,0,0" Margin="0,8" />
                        <WrapPanel>
                            <Image Source="https://freeiconshop.com/wp-content/uploads/edd/info-circle-outline.png" Margin="0,0,5,0"  Width="16" Height="16"/>
                            <TextBlock FontStyle="Italic">Press F1 for more help</TextBlock>
                        </WrapPanel>
                    </StackPanel>
                </Button.ToolTip>
            </Button>
        </ToolBar>
 
        <TextBox>
            Editor area...
        </TextBox>
    </DockPanel>
cs



고급 옵션


Tooltip이 있는 컨트롤에서 직접 설정합니다. ShowDuration 속성을 이용하여 5초(5000ms)동안 툴팁이 표시되도록합니다.

1
2
3
4
5
<Button ToolTip="Create a new file" ToolTipService.ShowDuration="5000">
5000ms 동안 툴팁을 보여줘!
                <Button.Content>
                    <Image Source="https://freeiconshop.com/wp-content/uploads/edd/document-add-outline.png" Width="16" Height="16" />
                </Button.Content>
 </Button>
cs


추가 툴팁 속성

'C# > WPF' 카테고리의 다른 글

WPF tutorial - Introduction to WPF panels  (0) 2017.06.22
WPF tutorial - WPF text rendering  (0) 2017.06.22
WPF tutorial - The PasswordBox control  (0) 2017.06.22
WPF tutorial - The RadioButton control  (0) 2017.06.22
WPF tutorial - The CheckBox control  (0) 2017.06.22
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
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
글 보관함