Click here to Skip to main content
15,898,371 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: How do I show balloon tips? Pin
michmela4426-Aug-09 8:44
michmela4426-Aug-09 8:44 
GeneralRe: How do I show balloon tips? Pin
Etienne_12327-Aug-09 7:01
Etienne_12327-Aug-09 7:01 
QuestionAccess files in a folder. Pin
Nekkantidivya25-Aug-09 21:42
Nekkantidivya25-Aug-09 21:42 
AnswerRe: Access files in a folder. Pin
Mark Salsbery26-Aug-09 8:14
Mark Salsbery26-Aug-09 8:14 
QuestionSystem.Reflection.TargetInvocationException Pin
Nekkantidivya25-Aug-09 1:27
Nekkantidivya25-Aug-09 1:27 
AnswerRe: System.Reflection.TargetInvocationException Pin
Mark Salsbery26-Aug-09 8:20
Mark Salsbery26-Aug-09 8:20 
NewsFree event for Silverlight developers -- join online or in person Pin
brucedkyle24-Aug-09 6:44
brucedkyle24-Aug-09 6:44 
QuestionAnnoying Binding Warning Pin
Super Lloyd24-Aug-09 2:38
Super Lloyd24-Aug-09 2:38 
I have the code (below) which runs fine however, when the applications starts, I got those 3 warning on the output window:
--
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=RotateX; DataItem=null; target element is 'RotateTransform' (HashCode=14303791); target property is 'CenterX' (type 'Double')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=RotateY; DataItem=null; target element is 'RotateTransform' (HashCode=14303791); target property is 'CenterY' (type 'Double')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=RotateAngle; DataItem=null; target element is 'RotateTransform' (HashCode=14303791); target property is 'Angle' (type 'Double')
--
Any clues on how to get rid of them?

Here is the code:
Window1.xaml
<Window 
	x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:WpfApplication1"
    Title="Window1" 
	Background="White"
	Height="300" Width="300">
	<DockPanel>
		<Button DockPanel.Dock="Bottom" Click="DoAdd">Add Item</Button>
		
		<ItemsControl x:Name="itemsDisplay">
			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<Canvas/>
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
			<ItemsControl.ItemTemplate>
				<DataTemplate DataType="{x:Type local:DataItem}">
					<Border
						Background="{Binding Brush}"
						Width="{Binding Width}"
						Height="{Binding Height}"
						>
						<Border.RenderTransform>
							<RotateTransform CenterX="{Binding RotateX}" CenterY="{Binding RotateY}" Angle="{Binding RotateAngle}"/>
						</Border.RenderTransform>
					</Border>
				</DataTemplate>
			</ItemsControl.ItemTemplate>
			<ItemsControl.ItemContainerStyle>
				<Style>
					<Setter Property="Canvas.Left" Value="{Binding X}"/>
					<Setter Property="Canvas.Top" Value="{Binding Y}"/>
				</Style>
			</ItemsControl.ItemContainerStyle>
		</ItemsControl>
	</DockPanel>
</Window>

Window1.xaml.cs
using System.Windows;

namespace WpfApplication1
{
	public partial class Window1 : Window
	{
		public Window1()
		{
			InitializeComponent();
		}

		private void DoAdd(object sender, RoutedEventArgs e)
		{
			itemsDisplay.Items.Add(new DataItem());
		}
	}
}

DataItem.cs
using System;
using System.Windows.Media;
using System.Reflection;

namespace WpfApplication1
{
	public class DataItem
	{
		static Random RAND = new Random();

		public DataItem()
		{
			X = RAND.Next(200);
			Y = RAND.Next(200);
			Width = 20 + 30 * RAND.NextDouble();
			Height = 10 + 20 * RAND.NextDouble();
			RotateAngle = 360 * RAND.NextDouble();

			var brushes = typeof(Brushes).GetProperties(BindingFlags.Static | BindingFlags.Public);
			Brush = brushes[RAND.Next(brushes.Length)].GetValue(null, null) as Brush;
		}

		public double X { get; set; }
		public double Y { get; set; }
		public double Width { get; set; }
		public double Height { get; set; }
		public double RotateAngle { get; set; }
		public Brush Brush { get; set; }

		public double RotateX { get { return Width / 2; } }
		public double RotateY { get { return Height / 2; } }
	}
}


A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

AnswerRe: Annoying Binding Warning Pin
Insincere Dave25-Aug-09 6:23
Insincere Dave25-Aug-09 6:23 
GeneralRe: Annoying Binding Warning Pin
Super Lloyd25-Aug-09 12:58
Super Lloyd25-Aug-09 12:58 
QuestionWPF Datagrid itemsource:This works but is it the best way ? plz [modified] Pin
prubyholl23-Aug-09 6:01
professionalprubyholl23-Aug-09 6:01 
AnswerRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
Christian Graus23-Aug-09 12:56
protectorChristian Graus23-Aug-09 12:56 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
prubyholl23-Aug-09 21:04
professionalprubyholl23-Aug-09 21:04 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
Christian Graus23-Aug-09 21:31
protectorChristian Graus23-Aug-09 21:31 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
prubyholl23-Aug-09 21:43
professionalprubyholl23-Aug-09 21:43 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
Christian Graus23-Aug-09 23:08
protectorChristian Graus23-Aug-09 23:08 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
prubyholl24-Aug-09 0:11
professionalprubyholl24-Aug-09 0:11 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
prubyholl24-Aug-09 1:06
professionalprubyholl24-Aug-09 1:06 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
Richard MacCutchan31-Aug-09 5:05
mveRichard MacCutchan31-Aug-09 5:05 
GeneralRe: WPF Datagrid itemsource:This works but is it the best way ? plz Pin
prubyholl31-Aug-09 6:03
professionalprubyholl31-Aug-09 6:03 
QuestionStrange Compile error , my Project Assemby cannot be found Pin
cppwxwidgetsss22-Aug-09 19:42
cppwxwidgetsss22-Aug-09 19:42 
AnswerRe: Strange Compile error , my Project Assemby cannot be found Pin
Richard MacCutchan31-Aug-09 5:13
mveRichard MacCutchan31-Aug-09 5:13 
QuestionProblem setting dialogresult in WPF [SOLVED] Pin
michmela4422-Aug-09 19:08
michmela4422-Aug-09 19:08 
AnswerRe: Problem setting dialogresult in WPF Pin
AspDotNetDev22-Aug-09 22:02
protectorAspDotNetDev22-Aug-09 22:02 
GeneralRe: Problem setting dialogresult in WPF Pin
michmela4423-Aug-09 6:28
michmela4423-Aug-09 6:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.