Click here to Skip to main content
15,885,921 members
Articles / Desktop Programming / WPF

WPF Tutorial - Part 1 : Transformations

,
Rate me:
Please Sign up or sign in to vote.
4.40/5 (56 votes)
28 Jun 2010CPOL6 min read 352.9K   7.9K   127  
A brief introduction to using transformations with the WPF
using System;
using System.IO;
using System.Net;
using System.Security;
using System.Security.Permissions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;

namespace TranformationExplorer
{
	public partial class MainApplication: System.Windows.Application
	{
		protected override void OnLoadCompleted(NavigationEventArgs e)
		{
			// Set the Window title.
			this.MainWindow.Title = "Application";

			// Get the window to take the size of its content, and then allow
			// it to be set by the user, and have the content take the size
			// of the window.
			if (!this.IsWebBrowserApplication)
			{
				this.MainWindow.SizeToContent = SizeToContent.WidthAndHeight;
				this.MainWindow.SizeToContent = SizeToContent.Manual;
			}

			FrameworkElement root = this.MainWindow.Content as FrameworkElement;
			if (root != null)
			{
				root.Height = double.NaN;
				root.Width = double.NaN;

				root.Focus();
			}
		}
		
		private bool IsWebBrowserApplication
		{
			get
			{
				try
				{
					PermissionSet testSet = new PermissionSet(PermissionState.None);
					testSet.AddPermission(new UIPermission(UIPermissionWindow.AllWindows));
					testSet.Assert();

					return false;
				}
				catch (SecurityException)
				{
					return true;
				}
			}
		}
	}
}

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 (Senior)
Australia Australia
Programming computers ( self taught ) since about 1984 when I bought my first Apple ][. Was working on a GUI library to interface Win32 to Python, and writing graphics filters in my spare time, and then building n-tiered apps using asp, atl and asp.net in my job at Dytech. After 4 years there, I've started working from home, at first for Code Project and now for a vet telemedicine company. I owned part of a company that sells client education software in the vet market, but we sold that and I worked for the owners for five years before leaving to get away from the travel, and spend more time with my family. I now work for a company here in Hobart, doing all sorts of Microsoft based stuff in C++ and C#, with a lot of T-SQL in the mix.

Written By
United States United States
Nish Nishant is a technology enthusiast from Columbus, Ohio. He has over 20 years of software industry experience in various roles including Chief Technology Officer, Senior Solution Architect, Lead Software Architect, Principal Software Engineer, and Engineering/Architecture Team Leader. Nish is a 14-time recipient of the Microsoft Visual C++ MVP Award.

Nish authored C++/CLI in Action for Manning Publications in 2005, and co-authored Extending MFC Applications with the .NET Framework for Addison Wesley in 2003. In addition, he has over 140 published technology articles on CodeProject.com and another 250+ blog articles on his WordPress blog. Nish is experienced in technology leadership, solution architecture, software architecture, cloud development (AWS and Azure), REST services, software engineering best practices, CI/CD, mentoring, and directing all stages of software development.

Nish's Technology Blog : voidnish.wordpress.com

Comments and Discussions