can't GetValue..
Last post 05-09-2008 5:52 PM by Gamewolf. 5 replies.
Sort Posts:
05-08-2008 12:01 AM
can't GetValue..

i try to use the GetValue to get the Fill Properties from a Path , i got a SolidColorBrush Return , can i get the SolidColorBrush's Color Properties ?

i  try to  use Javascript to parser the SOM. 

 and the path is i use js to create during runtime by client user ...

a_di0229

Joined on 05-06-2008
Posts 8
05-08-2008 5:29 PM
Re: can't GetValue..

I found a temporary solution. You can dynamically populate the SolidColorBrush's Color Property using Javascript. Here is an example:

 

<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Canvas Width="300" Height="300" MouseLeftButtonDown="splitData" Background="#aaaaaa">
        <Rectangle x:Name="rect1" Width="300" Height="300" Fill="Black" />
    </Canvas>
</Canvas>

Say you want to access the Fill Attribute from the Rectangle Instead of hard coding "Black" into the Fill Attribute, populate it dynamically like so:

function init(sender){
    var host = document.getElementById("mySilverlightPlugin");
    var root = host.Content.Root;
    var rectangleFill = "Black";
    //root.findName("rect1").Fill = rectangleFill;
}

 

Then you can access rectangleFill anytime. Until you find an easier way, this is what i'd use.

Hope this helps. 

 

Gamewolf

Joined on 05-05-2008
Posts 19
05-09-2008 6:10 AM
Re: can't GetValue..

if i can't using the SOM to find out the property . how about LinerGradientBrush..

 how can i set the Color to it ..??

 

a_di0229

Joined on 05-06-2008
Posts 8
05-09-2008 4:57 PM
Marked as Answer
Re: Re: can't GetValue..

For your situation, it would be like this:

XAML

<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Canvas Width="300" Height="300" Loaded="init" Background="#aaaaaa">
        <Path x:Name="myPath" Data="Data Here" />
    </Canvas>
</Canvas>

Javascript

function init(sender){
 var myPathFill = "Black";
 sender.findName("myPath").Fill = myPathFill;
}

That is all there is to it. Here is a post from another thread I was asking that should answer your questions.
http://silverlight.net/forums/t/15682.aspx It was posted by Yi-Lun Luo - MSFT.

--
Gamewolf

Gamewolf

Joined on 05-05-2008
Posts 19
05-09-2008 5:23 PM
Re: Re: Re: can't GetValue..

okay , i see. so i should keep all the data myself .thanks ..

a_di0229

Joined on 05-06-2008
Posts 8
05-09-2008 5:52 PM
Re: Re: Re: can't GetValue..

Your Welcome. 

Gamewolf

Joined on 05-05-2008
Posts 19