티스토리 뷰

C#/WPF

WPF tutorial - The WPF StatusBar control

광그로 2017. 7. 1. 23:58

http://www.wpf-tutorial.com/common-interface-controls/statusbar-control/


StatusBar(상태표시줄)은 커서의 위치, 단어의 수, 진행 상황 등 다양한 정보를 표시하는데 사용됩니다.

1
2
3
4
5
6
7
8
<DockPanel>
        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem>
                <TextBlock Name="lblCursorPosition"></TextBlock>
            </StatusBarItem>
        </StatusBar>
        <TextBox AcceptsReturn="True" Name="TxtEditor" SelectionChanged="TxtEditor_SelectionChanged" />
    </DockPanel>
cs
1
2
3
4
5
6
 private void TxtEditor_SelectionChanged(object sender, RoutedEventArgs e)
        {
            int row = TxtEditor.GetLineIndexFromCharacterIndex(TxtEditor.CaretIndex);
            int col = TxtEditor.CaretIndex - TxtEditor.GetCharacterIndexFromLineIndex(row);
            lblCursorPosition.Text = "Line " + (row + 1+ ", Char " + (col + 1);
        }
cs


Advanced StatusBar example


StatusBar내에서 Grid를 통하여 레이아웃을 설정합니다.

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
<DockPanel>
        <StatusBar DockPanel.Dock="Bottom">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="100" />
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem>
                <TextBlock Name="lblCursorPosition" />
            </StatusBarItem>
            <Separator Grid.Column="1" />
            <StatusBarItem Grid.Column="2">
                <TextBlock Text="c:\path\of\current\file.txt" />
            </StatusBarItem>
            <Separator Grid.Column="3" />
            <StatusBarItem Grid.Column="4">
                <ProgressBar Value="50" Width="90" Height="16" />
            </StatusBarItem>
        </StatusBar>
 
        <TextBox AcceptsReturn="True" Name="txtEditor" SelectionChanged="txtEditor_SelectionChanged" />
 
    </DockPanel>
cs

1
2
3
4
5
6
 private void txtEditor_SelectionChanged(object sender, RoutedEventArgs e)
        {
            int row = txtEditor.GetLineIndexFromCharacterIndex(txtEditor.CaretIndex);
            int col = txtEditor.CaretIndex - txtEditor.GetCharacterIndexFromLineIndex(row);
            lblCursorPosition.Text = "Line " + (row + 1+ ", Char " + (col + 1);
        }
cs



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

WPF tutorial - The Border control  (0) 2017.07.02
WPF tutorial - The Ribbon control  (0) 2017.07.02
WPF tutorial - The WPF ToolBar control  (0) 2017.07.01
WPF tutorial - The WPF ContextMenu  (0) 2017.07.01
WPF tutorial - The WPF Menu control  (0) 2017.06.29
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함