다음을 통해 공유


GridSplitter.ShowsPreview Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a value that indicates whether the GridSplitter control updates the column or row size as the user drags the control with the mouse.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls (in System.Windows.Controls.dll)

Syntax

'Declaration
Public Property ShowsPreview As Boolean
public bool ShowsPreview { get; set; }
<sdk:GridSplitter ShowsPreview="bool"/>

Property Value

Type: System.Boolean
true if a preview is displayed; otherwise, false.

Remarks

Dependency property identifier field: ShowsPreviewProperty

When the ShowsPreview property is set to true, a preview of the change in the row or column sizes is shown. The actual size changes when the GridSplitter is released. If the property is set to false, the column or row sizes are updated in real time as the user drags the GridSplitter control.

When the GridSplitter control is moved with the keyboard, column or row sizes are updated in real time regardless of the ShowsPreview value.

Examples

Run this sample

The following XAML creates two GridSplitter controls, one vertical and one horizontal. The horizontal control shows a preview, whereas the vertical one does not.

<!-- NOTE: 
  By convention, the sdk prefix indicates a URI-based XAML namespace declaration 
  for Silverlight SDK client libraries. This namespace declaration is valid for 
  Silverlight 4 only. In Silverlight 3, you must use individual XAML namespace 
  declarations for each CLR assembly and namespace combination outside the scope 
  of the default Silverlight XAML namespace. For more information, see the help 
  topic "Prefixes and Mappings for Silverlight Libraries". 
-->
<UserControl x:Class="GridSplitterExample.Page"
        xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:sdk="https://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"             
        Width="450"
        Height="500"
        >
    <Canvas x:Name="LayoutRoot" Background="White" >
        <Grid ShowGridLines="True" Canvas.Top="60" Canvas.Left="20" Width="400" Height="400">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock Text="One!" Grid.Row="0" Grid.Column="0" />
            <TextBlock Text="Two!" Grid.Row="1" Grid.Column="1" />
            <TextBlock Text="Three!" Grid.Row="2" Grid.Column="2" />
            <TextBlock Text="Four!" Grid.Row="3" Grid.Column="3" />
            <sdk:GridSplitter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4"
                               Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                               ShowsPreview="True"
                                />
            <sdk:GridSplitter Grid.Row="2" Grid.Column="1" Grid.RowSpan="2"
                               Width="5" HorizontalAlignment="Left" VerticalAlignment="Stretch"
                                />
       </Grid>
     </Canvas>
</UserControl>

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.