Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Shapenode and shadow using shapegemotry (Read 1227 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Shapenode and shadow using shapegemotry
Mar 29th, 2010 at 8:01am
Print Post  
Hi Stoyo

In my application, for node when i specify shadow, it gives me performance issue with scrolling. In one of your reply, you suggested use another nodes with by setting offset.

In Tutorial 3, I tried to use ShapeGeometry for rendering two shapes ( another one use few offset ) but that gives me xaml parsing error.

I used following code
Code
Select All
<ControlTemplate TargetType="local:OrgChartNode">
<Canvas x:Name="Adorner">

<Path Data="{TemplateBinding ShapeGeometry}"
Stroke="{TemplateBinding Stroke}"
Fill="{TemplateBinding Brush}" />


<Path Canvas.Left="20" Canvas.Top="20"
Data="{TemplateBinding ShapeGeometry}"
Stroke="{TemplateBinding Stroke}"
Fill="Black" />
</Canvas>
 



Can you help me in this regards.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shapenode and shadow using shapegemotry
Reply #1 - Mar 29th, 2010 at 10:08am
Print Post  
It seems Silverlight does not allow DependencyObjects to be shared between more than one visual parents. We had a similar problem with StrokeDashArrays, and as a workaround used an IValueConverter that clones the specified dash array and assigned such converter to the binding. In this case the following works fine:

Code
Select All
public class GeometryConverter : IValueConverter
{
	public object Convert(object value, Type targetType, object parameter,
		System.Globalization.CultureInfo culture)
	{
		if (targetType == typeof(Geometry))
		{
			ShapeNode src = value as ShapeNode;
			if (src != null)
				return src.Shape.CreateOutlineGeometry(src.Bounds.Width, src.Bounds.Height);
		}
		return value;
	}

	public object ConvertBack(object value, Type targetType, object parameter,
		System.Globalization.CultureInfo culture)
	{
		throw new NotImplementedException();
	}
}

<Canvas.Resources>
	<local:GeometryConverter x:Key="geometryConverter"/>
</Canvas.Resources>

<Path Canvas.Left="30" Canvas.Top="30"
	Data="{Binding Path=., RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource geometryConverter}}"
	Stroke="{TemplateBinding Stroke}"
	Fill="Black" /> 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint