Search This Blog

Showing posts with label ContentControl. Show all posts
Showing posts with label ContentControl. Show all posts

Wednesday, July 26, 2017

GridViewColumnHeader WPF Example

WPF > Controls  > ContentControl > GridViewColumnHeader

GridViewColumnHeader object is a button control that is derived from ButtonBase. 
Column headers in a GridView view mode are GridViewColumnHeader objects.
Example

<Window x:Class="GridViewColumnHeader.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:GridViewColumnHeader"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <ListView>
            <ListView.View>
                <GridView>
                    <GridViewColumn>
                        <GridViewColumnHeader>Name
                            <GridViewColumnHeader.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Ascending" />
                                    <MenuItem Header="Descending" />
                                </ContextMenu>
                            </GridViewColumnHeader.ContextMenu>
                        </GridViewColumnHeader>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</Window>



Friday, February 26, 2016

StatusBarItem Example WPF

WPF > Controls  > ContentControl > StatusBarItem

StatusBarItem objects are used to define items in a StatusBar control.





<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StatusBar Name="sbar"
           VerticalAlignment="Bottom" >
            <StatusBar.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="#FFAE1B1B" Offset="1"/>
                </LinearGradientBrush>
            </StatusBar.Background>
            <StatusBarItem>
                <TextBlock Foreground="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}">Processsing</TextBlock>
            </StatusBarItem>
            <StatusBarItem>
                <ProgressBar Width="100" Height="20"
                 Name="progressBar1">
                    <ProgressBar.Triggers>
                        <EventTrigger RoutedEvent="ProgressBar.Loaded">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                Storyboard.TargetName="progressBar1"
                Storyboard.TargetProperty="Value"
                From="0" To="100" Duration="0:0:5"  />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ProgressBar.Triggers>
                </ProgressBar>
            </StatusBarItem>
            <Separator/>
            <StatusBarItem>
                <TextBlock Foreground="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}">Percent</TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>

</Window>

Wednesday, January 27, 2016

ToogleButton WPF Example

WPF > Controls  > ContentControl > ToogleButton

Toggle button is similar to CheckBox control. It holds its state when it clicked.

Example 
On/Off Button






<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">
            <Setter Property="Content" Value="Off"/>
            <Setter Property="Foreground" Value="Red" />
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Content" Value="On">
                    </Setter>
                    <Setter Property="Foreground" Value="Green" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <ToggleButton Name="btnToogle" IsChecked="True"
                    Height="30" Width="70"
                      Style="{StaticResource ToggleButtonStyle}">
        </ToggleButton>
    </Grid>
</Window> 



Wednesday, January 6, 2016

ListBoxItem Example WPF

WPF > Controls  > ContentControl > ListBoxItem

ListBoxItem represents a selectable item in a ListBox.

Example




<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <ListBox HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100">
            <ListBoxItem Content="1"/>
            <ListBoxItem Content="2"/>
        </ListBox>
    </Grid>
</Window>




Wednesday, November 4, 2015

Label WPF Example

WPF > Controls  > ContentControl > Label

This control represents the text label for a control and provides support for access keys.

Example

The following example shows how to create a Label that has an access key and uses a binding to set the target.

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox Name="textBox" Margin="49,0,281,291"/>
        <Label Target="{Binding ElementName=textBox}">_Name</Label>
    </Grid>

</Window>