Display Attribute Values into HTML
Last post 05-09-2008 2:53 AM by Yi-Lun Luo - MSFT. 3 replies.
Sort Posts:
05-07-2008 6:58 PM
Display Attribute Values into HTML

I am wanting to display a the value of a data attribute of a path tag into a div tag in html. I cannot seem to get it to work. This is what I have:

 XAML

<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Canvas Width="300" Height="300" MouseLeftButtonDown="splitData">
        <Rectangle x:Name="button" Width="50" Height="25" Canvas.Top="100" Stroke="Black" Fill="White" />
        <Path x:Name="Text" Stroke="Black" Fill="Black" Data="Data Here" />
    </Canvas>
</Canvas>

 

Javascript

 

function splitData(sender, mouseEventArgs){
    var myText = sender.findName("Text").Data;
    document.getElementById("pathText").innerHTML=myText;
}

 

I have tried toString() also and it doesn't work. When I click somewhere on the canvas, it only displays "PathGeometry". It won't display my data.

Any help would be appreciated. Thank. 

Gamewolf

Joined on 05-05-2008
Posts 19
05-08-2008 1:43 AM
Re: Display Attribute Values into HTML

Hello,

I have posted early this how to get silverlight reffernce in html.I m again giving it to u.

var host=document.getElementById("silverlightcontrolhost");

//silverlightcontrolhost is id for u r silverlight plugin not div

var root=host.Content.Root;

//retrieves the reffernce of u r   root element

& then

root.findName("pathText") 

 

Hitesh

 

If this answer u r que Plz mark as answer

 

hiteshbhagwat

Joined on 10-05-2007
Posts 18
05-08-2008 5:11 PM
Re: Display Attribute Values into HTML

Ok I did what you said and it still only says "PathGeometry". 

Gamewolf

Joined on 05-05-2008
Posts 19
05-09-2008 2:53 AM
Marked as Answer
Re: Re: Display Attribute Values into HTML

Hello, the mini path language you write for Path.Data will be transformed to a PathGeometry when the runtime parses XAML. There's no way to get the original string after XAML is parsed.

shanaolanxing - Please mark the posts as answers if they help and unmark if they don't.

Yi-Lun Luo - MSFT

Joined on 10-29-2007
Posts 1,084