locked
Problem with findName RRS feed

  • General discussion

  • Hi

    I am having problems getting values from .xaml file. In my .aspx page i have

     

    <!-- Silverlight control-->

    <div id="mySilverlightControlHost">

    </div>

    <script type="text/javascript"> var parentElement = document.getElementById("mySilverlightControlHost");

    createMySilverlightControl();

    </script>

    <!-- Find the Polygon collection points -->

    <script language="javascript" type="text/javascript">

    function getPoly() {

    // Get a reference to the Host itself

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

    // Find a specific element

    var polyPoints = host.findName("1001").Points;

    // Show Polygon Points

    alert("Polygon Points " + polyPoints);

    }

    </script>

     

    my xaml file has this

    <Polygon x:Name="1001" Points="200,200 200,500 500,500 500,200" Stroke="Black" StrokeThickness="1" Fill="#669900" StrokeDashArray="10 10" />

    Any ideas?

    Dylan 

     

    Tuesday, May 1, 2007 3:42 PM

All replies

  • hello

    There most be something with the content if you use the function getHost();

    function myFunc(Sender, Args)
    {
         var myHost = Sender.getHost();
         var playButton = myHost.content.findName("1001");
    }

    Don't know if this is the problem. else take a look at:
    http://msdn2.microsoft.com/en-us/library/bb232842.aspx 

    Bye

    Wednesday, May 2, 2007 8:03 AM
  • And make sure the control has loaded – the control might not have parsed and loaded the XAML yet so the findname would not work yet. You can listen to the controls' OnLoad event to know when the control has loaded the XAMl.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"
    Wednesday, May 2, 2007 2:26 PM