Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Setting StrokeThickness at runtime (Read 3762 times)
fireboy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Dec 17th, 2009
Setting StrokeThickness at runtime
Mar 16th, 2010 at 3:49pm
Print Post  
Hi,
I have a problem. When I change StrokeThickness at runtime the shape is not redrawn and the actual stroke thickness does not change. Looks like it's not a dependency property and it's only respected once in a ShapeNode's lifetime.
I need to be able to change StrokeThickness at runtime, any ideas how to accomplish that?

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Setting StrokeThickness at runtime
Reply #1 - Mar 16th, 2010 at 6:02pm
Print Post  
Hi,

It is a dependency property and the Path object used in the ShapeNode template binds to it. It seems the Path itself does not handle the thickness change notification. However setting the stroke color works fine, so you might just assign the default color after thickness to force the Path to repaint:

node.StrokeThickness += 1;
node.Stroke = new SolidColorBrush(Colors.Black);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
fireboy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Dec 17th, 2009
Re: Setting StrokeThickness at runtime
Reply #2 - Mar 17th, 2010 at 9:22am
Print Post  
Your suggestion does not work for me.
Only color changes, but thickness still remains unchanged. Does that code work for you?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Setting StrokeThickness at runtime
Reply #3 - Mar 17th, 2010 at 9:27am
Print Post  
Yes, it does. What kind of Shape are you using?
  
Back to top
 
IP Logged
 
fireboy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Dec 17th, 2009
Re: Setting StrokeThickness at runtime
Reply #4 - Mar 17th, 2010 at 9:38am
Print Post  
OK it works for a standard ShapeNode (with Shape=Ellipse).
I have subclassed the ShapeNode and set the Shape to "Ellipse" in one of the methods of my class. In this scenario StrokeThickness does not work.
  
Back to top
 
IP Logged
 
fireboy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Dec 17th, 2009
Re: Setting StrokeThickness at runtime
Reply #5 - Mar 17th, 2010 at 9:41am
Print Post  
Never mind, got it working.
The XAML template for my shape was not binding the StrokeThickness property of the Path.
I changed it into this:
Code
Select All
<Path
				    Data="{TemplateBinding ShapeGeometry}"
				    Stroke="{TemplateBinding Stroke}"
				    StrokeThickness="{TemplateBinding StrokeThickness}"
				    Fill="{TemplateBinding Brush}" />
 



It was a copy-paste from your sample and i just overlooked this.
Thanks anyway for the solution!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint