Slider:表示一种控件,该控件使用户可以通过沿着一条轨道移动 Thumb 控件来从一个值范围中进行选择。(官方文档上面写的很难懂,其实就是一个可以用鼠标拖拉来改变值的条)

<Window x:Class="MaterialStorage.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>
        <!--在这里给网格定义了三行一列 第一行高20 第三行高20 其余的自适应-->
        <Grid.RowDefinitions>
            <RowDefinition Height="20"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="20"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" ></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Button Grid.Row="0">按钮1</Button>
        <!-- Border 被单独拿出来,用于为一些容器绘制边框-->
        <Border BorderThickness="3" BorderBrush="Black" Grid.Row="1">
            <StackPanel x:Name="LayoutRoot" Margin="10,10,10,10">
                <TextBlock Text="Basic Slider:" />
                <Slider Margin="0,5,0,20" x:Name="slider1" Minimum="0" Maximum="10" />
                <TextBlock Text="Slider with ValueChanged event handler:" />
                <Slider Margin="0,5,0,0" x:Name="slider2" Minimum="0" Maximum="10" ValueChanged="slider2_ValueChanged" />
                <TextBlock Margin="0,5,0,20" x:Name="textBlock1" Text="Current value: 0" />
                <TextBlock Text="Slider with vertical orientation:" />
                <Slider Margin="0,5,0,20" x:Name="slider3" Minimum="0" Maximum="10" Height="20" Orientation="Vertical"/>
                <TextBlock Text="Slider with reversed direction:" />
                <Slider Margin="0,5,0,20" x:Name="slider4" Minimum="0" Maximum="10" IsDirectionReversed="true"/>
            </StackPanel>
        </Border>
        <Button Grid.Row="2">按钮3</Button>
    </Grid>
</Window>

posted on 2013-02-28 17:20  振宇爸爸  阅读(337)  评论(0编辑  收藏  举报