Export (0) Print
Expand All

ScatterViewItem Class

Surface 1.0 SP1
Represents an item that users can manipulate in a ScatterView control.

Namespace: Microsoft.Surface.Presentation.Controls
Assembly: Microsoft.Surface.Presentation (in microsoft.surface.presentation.dll)

'Usage
Dim instance As ScatterViewItem

public class ScatterViewItem : SurfaceContentControl
public class ScatterViewItem extends SurfaceContentControl
public class ScatterViewItem extends SurfaceContentControl

ScatterViewItem controls are inserted into the Items collection of a ScatterView control to enable movement and manipulation of objects of any type on the Microsoft Surface screen. Your application can explicitly create ScatterViewItem controls before adding them to the Items collection, or you can add an object of any type. When you add an object that is not of type ScatterViewItem, the ScatterView control first wraps your object in a ScatterViewItem control before adding it to the collection. The following code example illustrates this behavior.

<UserControl 
    x:Class="Classes_ScatterView.Controls.ScatterViewControl2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008" 
    Background="Aquamarine">
    <s:ScatterView Name="MainScatterView">
        <!-- Explicitly place controls in a ScatterViewItem control-->
        <s:ScatterViewItem DecelerationRate="57.25">
            <Label Content="1. Pizza"/>
        </s:ScatterViewItem>
        <s:ScatterViewItem DecelerationRate="128.90">
            <Label Content="2. Laundry"/>
        </s:ScatterViewItem>
        <!-- This label will automatically be wrapped in a ScatterViewItem control-->
        <Label Content="3. Movie"/>
    </s:ScatterView>
</UserControl>

The same concept applies when you add an object to the Items collection programmatically, as the following code examples illustrate.

The following code example demonstrates how to add an item without explicitly creating a ScatterViewItem control.


#region AddScatterViewItem
private void AddScatterViewItem(ScatterView scatterView)
{
    Label label = new Label();
    label.Content = "Item " + (scatterView.Items.Count + 1).ToString();
    label.Margin = new Thickness(6);
    scatterView.Items.Add(label);
}
#endregion

The following code example demonstrates how to add an item b explicitly creating a ScatterViewItem control.


#region AddScatterViewItem
private void AddScatterViewItem(ScatterView scatterView)
{
    Label label = new Label();
    label.Content = "Item " + (scatterView.Items.Count + 1).ToString();
    label.Margin = new Thickness(6);
    ScatterViewItem item = new ScatterViewItem();
    item.Orientation = 30.0;
    item.Content = label;
    scatterView.Items.Add(item);
}
#endregion

You can add a ScatterViewItem control to the Items collection without layout properties that are explicitly established. If so, values for the following properties are assigned automatically:

The values that are assigned in this manner are not entirely random. When adding items without explicit layout information, the ScatterView control considers the content size of the items and the positioning of existing items.

If it is needed, your application can assign the layout properties explicitly as the following code example illustrates.

<UserControl 
    x:Class="Classes_ScatterView.Controls.ScatterViewControl3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008" 
    Background="Cyan">
    <s:ScatterView Name="MainScatterView">
        <!-- This item will be assigned values for Center, Height, Width, and Orientation-->
        <s:ScatterViewItem>
            <Label Content="Bus"/>
        </s:ScatterViewItem>
        <!-- This item assigns the layout properties explicitly -->
        <s:ScatterViewItem Center="300,300" Height="72" Width="132" Orientation="45.0">
            <Label Content="Automobile"/>
        </s:ScatterViewItem>
    </s:ScatterView>
</UserControl>

After a ScatterViewItem control has been inserted into the Items collection, users can manipulate it on the Microsoft Surface screen in a variety of ways. By using simple gestures, users can move, rotate, and scale the ScatterViewItem control. These manipulations can occur simultaneously.

If you want to limit the manipulations that users can perform on a ScatterViewItem control, you can set the CanScale or CanRotate properties to false.

When contacts that were captured by the ScatterViewItem control are released, inertia processing is used to gradually slow the movement and rotation. You can control the speed at which the inertia processing occurs through the DecelerationRate and AngularDecelerationRate properties. As an item is decelerating, if it encounters the bounds of its parent ScatterView control, it bounces and decelerates more rapidly.

Activation and Deactivation

A ScatterView control activates a ScatterViewItem control when a user starts manipulating the item. By default, when a ScatterViewItem object is activated, it grows slightly larger and displays a shadow beneath it. To disable these effects, set the ShowsActivationEffects property to false.

You can also change the activation state of a ScatterViewItem control programmatically. The Activate and Deactivate methods and the IsActive and StaysActive properties enable you to control the activation state in the manner that your application requires.

noteNote
ScatterViewItemScatterViewItem is a special type of Microsoft Windows Presentation Foundation (WPF) control. Most WPF controls enable you to set a RenderTransform property on the control itself. However, ScatterViewItem uses this property internally and will overwrite any value that you set. Avoid setting the RenderTransform property on ScatterViewItem or you will get unpredictable results. Instead of using RenderTransform, modify the ScatterViewItem control template.


System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.ContentControl
                 Microsoft.Surface.Presentation.Controls.SurfaceContentControl
                  Microsoft.Surface.Presentation.Controls.ScatterViewItem

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Microsoft Surface 1.0 SP1, Windows Vista Ultimate, Windows Vista Enterprise, Windows Vista Business

Target Platforms

Microsoft Surface 1.0 SP1
Show:
© 2014 Microsoft