Click here to Skip to main content
15,896,726 members
Articles / Desktop Programming / WPF

Custom Sized ScatterViewItems

Rate me:
Please Sign up or sign in to vote.
4.17/5 (6 votes)
9 Dec 2010CPOL8 min read 28.6K   832   10  
Demonstrates how to set the initial size of ScatterViewItems based on the content's requested size.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using Microsoft.Surface.Presentation;
using Microsoft.Surface.Presentation.Controls;
using Microsoft.Surface.Presentation.Input;

namespace ScatterViewSizingSample
{
	/// <summary>
	/// Interaction logic for SurfaceWindow1.xaml
	/// </summary>
	public partial class SurfaceWindow1 : SurfaceWindow
	{
		/// <summary>
		/// Default constructor.
		/// </summary>
		public SurfaceWindow1()
		{
			InitializeComponent();
		}

		private void btnNoSize_Click(object sender, RoutedEventArgs e)
		{
			sv.Items.Add(new PopupWindow(new NoSizeChild()));	
		}

		private void btnFixedSize_Click(object sender, RoutedEventArgs e)
		{
			sv.Items.Add(new PopupWindow(new FixedSizeChild()));
		}

		private void btnRandomSize_Click(object sender, RoutedEventArgs e)
		{
			sv.Items.Add(new PopupWindow(new RandomSizeChild()));
		}

		private void btnClear_Click(object sender, RoutedEventArgs e)
		{
			sv.Items.Clear();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer ABB
Sweden Sweden
My name is Isak Savo and I work as a Research Engineer at ABB Corporate Research in Västerås, Sweden. My work is focused around user experience which includes a lot of prototyping of new solutions for user interfaces and user interaction.

While I have a background in C programming in a Linux environment, my daily work is mostly spent in Windows using C# and WPF.

Comments and Discussions