<asp:Silverlight control not rendering all Xaml

Last post 04-16-2008 10:22 PM by InfinitiesLoop. 7 replies.

Sort Posts:

  • <asp:Silverlight control not rendering all Xaml

    04-07-2008, 11:03 PM
    • Loading...
    • datagrid
    • Joined on 05-23-2007, 1:01 PM
    • USA
    • Posts 461

    I created a Xaml file using Expression Blend: Following is the corresponding Xaml. But, I am not able to render the Xaml using the Silverlight control. I also tried the SilverlightPad with no success.

    Why is the Silverlight control not rendering all Xaml files? 

    <UserControl

     xmlns="http://schemas.microsoft.com/client/2007"

     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

     mc:Ignorable="d"

     x:Class="BuildingBlocks.XAMLbitIcon" Height="42" Width="58">

     <Canvas x:Name="LayoutRoot" >

    <!-- Layer 1/<Logo>/<Group>/<Path> -->

      <Path Data="F1 M 38.961426,19.708984 C 38.961426,25.222656 34.493164,29.689453 28.979492,29.689453 C 23.467773,29.689453 18.999023,25.222656 18.999023,19.708984 C 18.999023,14.197266 23.467773,9.728516 28.979492,9.728516 C 34.493164,9.728516 38.961426,14.197266 38.961426,19.708984 Z">

       <Path.Fill>

        <RadialGradientBrush MappingMode="Absolute" GradientOrigin="223.657715,411.188965" Center="223.657715,411.188965" RadiusX="9.152744" RadiusY="9.152744">

         <RadialGradientBrush.Transform>

          <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

         </RadialGradientBrush.Transform>

         <GradientStop Offset="0.089888" Color="#ffffffff"/>

         <GradientStop Offset="0.516854" Color="#ffff0000"/>

         <GradientStop Offset="1.000000" Color="#ff8e0000"/>

        </RadialGradientBrush>

       </Path.Fill>

      </Path>

      <Canvas>

       <!-- Layer 1/<Logo>/<Group>/<Group>/<Compound Path> -->

       <Path Data="F1 M 12.676758,0.263672 C 11.126953,0.261719 9.322754,1.322266 8.570801,2.679688 L 0.547363,17.142578 C -0.197754,18.486328 -0.180176,20.582031 0.586914,21.916016 L 10.243652,38.675781 C 11.013672,40.013672 12.827637,41.060547 14.370605,41.060547 L 23.809570,41.060547 C 24.744629,41.060547 25.479492,40.683594 25.824219,40.029297 C 26.168945,39.375000 26.062500,38.556641 25.531738,37.783203 L 13.868164,20.835938 C 13.391602,20.140625 13.394043,18.925781 13.872559,18.234375 L 24.049316,3.544922 C 24.582520,2.775391 24.693359,1.957031 24.348633,1.300781 C 24.006836,0.646484 23.271973,0.269531 22.333984,0.267578 L 12.676758,0.263672 Z M 22.333984,2.117188 C 22.634766,2.117188 22.734375,2.191406 22.735352,2.191406 C 22.719238,2.177734 22.698730,2.140625 22.697754,2.119141 C 22.697754,2.119141 22.700684,2.244141 22.528809,2.492188 L 12.354492,17.179688 C 11.439941,18.496094 11.437500,20.562500 12.345215,21.882813 L 24.008301,38.832031 C 24.179688,39.080078 24.175293,39.205078 24.175293,39.207031 C 24.176270,39.185547 24.194824,39.150391 24.211914,39.136719 C 24.209961,39.136719 24.110352,39.210938 23.809570,39.210938 L 14.370605,39.210938 C 13.474121,39.210938 12.293457,38.529297 11.844727,37.751953 L 2.188965,20.992188 C 1.736816,20.208984 1.726563,18.828125 2.165527,18.039063 L 10.188477,3.576172 C 10.620605,2.794922 11.783203,2.111328 12.674316,2.111328 L 22.333984,2.117188 Z">

        <Path.Fill>

         <LinearGradientBrush MappingMode="Absolute" StartPoint="210.011719,428.345703" EndPoint="210.011719,387.662689">

          <LinearGradientBrush.Transform>

           <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

          </LinearGradientBrush.Transform>

          <GradientStop Offset="0.000000" Color="#ff3e3e3e"/>

          <GradientStop Offset="1.000000" Color="#ff000000"/>

         </LinearGradientBrush>

        </Path.Fill>

       </Path>

      </Canvas>

      <Canvas>

       <!-- Layer 1/<Logo>/<Group>/<Group>/<Compound Path> -->

       <Path Data="F1 M 45.391602,2.111328 C 46.284180,2.111328 47.444824,2.794922 47.878418,3.576172 L 55.901855,18.039063 C 56.340820,18.828125 56.328613,20.208984 55.878418,20.992188 L 46.221680,37.751953 C 45.772949,38.529297 44.593262,39.210938 43.694824,39.210938 L 34.258789,39.210938 C 33.956055,39.210938 33.856445,39.136719 33.854492,39.136719 C 33.871094,39.150391 33.890625,39.185547 33.891602,39.207031 C 33.891602,39.205078 33.887695,39.080078 34.058594,38.832031 L 45.720703,21.882813 C 46.629883,20.562500 46.626465,18.496094 45.713379,17.179688 L 35.537109,2.492188 C 35.366211,2.244141 35.369629,2.119141 35.369629,2.119141 C 35.368652,2.140625 35.348633,2.177734 35.332031,2.191406 C 35.332031,2.191406 35.432129,2.117188 35.733398,2.117188 C 35.733398,2.117188 45.392578,2.111328 45.391602,2.111328 Z M 35.732422,0.267578 C 34.795410,0.269531 34.060547,0.646484 33.717285,1.300781 C 33.374512,1.957031 33.483398,2.775391 34.018555,3.544922 L 44.193359,18.234375 C 44.672852,18.925781 44.674316,20.140625 44.197266,20.835938 L 32.534180,37.783203 C 32.003418,38.556641 31.897461,39.375000 32.241699,40.029297 C 32.586426,40.683594 33.320801,41.060547 34.258789,41.060547 L 43.694824,41.060547 C 45.239746,41.060547 47.053223,40.013672 47.823730,38.675781 L 57.480469,21.916016 C 58.248047,20.582031 58.266113,18.486328 57.519531,17.142578 L 49.495117,2.679688 C 48.743652,1.322266 46.940918,0.261719 45.391602,0.263672 L 35.732422,0.267578 Z">

        <Path.Fill>

         <LinearGradientBrush MappingMode="Absolute" StartPoint="242.055176,428.346680" EndPoint="242.055176,387.664154">

          <LinearGradientBrush.Transform>

           <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

          </LinearGradientBrush.Transform>

          <GradientStop Offset="0.000000" Color="#ffbe0000"/>

          <GradientStop Offset="1.000000" Color="#ff620000"/>

         </LinearGradientBrush>

        </Path.Fill>

       </Path>

      </Canvas>

    <!-- Layer 1/<Logo>/<Group>/<Path> -->

      <Path Data="F1 M 35.732422,1.193359 C 34.512695,1.193359 34.082031,2.015625 34.777832,3.017578 L 44.953613,17.707031 C 45.648926,18.710938 45.650879,20.353516 44.959961,21.359375 L 33.297363,38.308594 C 32.605957,39.312500 33.037109,40.136719 34.258789,40.136719 L 43.694824,40.136719 C 44.915527,40.136719 46.412598,39.271484 47.022461,38.212891 L 56.679199,21.453125 C 57.288574,20.396484 57.302734,18.656250 56.709961,17.589844 L 48.686523,3.126953 C 48.095215,2.060547 46.612305,1.187500 45.391602,1.187500 L 35.732422,1.193359 Z">

       <Path.Fill>

        <LinearGradientBrush MappingMode="Absolute" StartPoint="242.056641,388.690430" EndPoint="242.056641,426.908356">

         <LinearGradientBrush.Transform>

          <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

         </LinearGradientBrush.Transform>

         <GradientStop Offset="0.000000" Color="#ffff0000"/>

         <GradientStop Offset="1.000000" Color="#ff8e0000"/>

        </LinearGradientBrush>

       </Path.Fill>

      </Path>

    <!-- Layer 1/<Logo>/<Group>/<Path> -->

      <Path Data="F1 M 22.333984,1.193359 C 23.554199,1.193359 23.984863,2.015625 23.289551,3.017578 L 13.113281,17.707031 C 12.417969,18.710938 12.415527,20.353516 13.108398,21.359375 L 24.769043,38.308594 C 25.461426,39.312500 25.029297,40.136719 23.809570,40.136719 L 14.370605,40.136719 C 13.150879,40.136719 11.653809,39.271484 11.043945,38.212891 L 1.388672,21.453125 C 0.778320,20.396484 0.764160,18.656250 1.356934,17.589844 L 9.378906,3.126953 C 9.973145,2.060547 11.454590,1.187500 12.675293,1.187500 L 22.333984,1.193359 Z">

       <Path.Fill>

        <LinearGradientBrush MappingMode="Absolute" StartPoint="210.010254,388.895508" EndPoint="210.010254,427.113434">

         <LinearGradientBrush.Transform>

          <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

         </LinearGradientBrush.Transform>

         <GradientStop Offset="0.000000" Color="#ff3e3e3e"/>

         <GradientStop Offset="1.000000" Color="#ff000000"/>

        </LinearGradientBrush>

       </Path.Fill>

      </Path>

      <Canvas x:Name="Highlights">

       <!-- Layer 1/<Logo>/<Group>/<Group>/<Path> -->

       <Path Opacity="0.750000" Data="F1 M 22.333984,1.193359 L 12.675293,1.187500 C 11.454590,1.187500 9.973145,2.060547 9.378906,3.126953 L 4.615723,11.714844 C 9.853516,10.458984 14.057129,9.132813 19.551758,8.414063 L 23.289551,3.017578 C 23.984863,2.015625 23.554199,1.193359 22.333984,1.193359 Z">

        <Path.Fill>

         <LinearGradientBrush MappingMode="Absolute" StartPoint="211.118652,426.909180" EndPoint="211.118652,409.650330">

          <LinearGradientBrush.Transform>

           <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

          </LinearGradientBrush.Transform>

          <GradientStop Offset="0.000000" Color="#ffffffff"/>

          <GradientStop Offset="1.000000" Color="#FFB1B1B1"/>

         </LinearGradientBrush>

        </Path.Fill>

       </Path>

       <!-- Layer 1/<Logo>/<Group>/<Group>/<Path> -->

       <Path Opacity="0.750000" Data="F1 M 48.686523,3.126953 C 48.095215,2.060547 46.612305,1.187500 45.391602,1.187500 L 35.732422,1.193359 C 34.512695,1.193359 34.082031,2.015625 34.777832,3.017578 L 38.487793,8.375000 C 42.533203,8.740234 47.172852,9.320313 52.593262,10.169922 L 48.686523,3.126953 Z">

        <Path.Fill>

         <LinearGradientBrush MappingMode="Absolute" StartPoint="240.519043,426.909180" EndPoint="240.519043,409.647491">

          <LinearGradientBrush.Transform>

           <MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-197.000000,428.443359" />

          </LinearGradientBrush.Transform>

          <GradientStop Offset="0.000000" Color="#ffffffff"/>

          <GradientStop Offset="1.000000" Color="#ffb1b1b1"/>

         </LinearGradientBrush>

        </Path.Fill>

       </Path>

      </Canvas>

     </Canvas>

    </UserControl>

    Das (http://aspalliance.com/author.aspx?uId=697)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you. This marks your thread as Resolved so we will all know you have been helped.
  • Re: <asp:Silverlight control not rendering all Xaml

    04-08-2008, 11:09 AM

    Hi,

    I used your xaml, and inserted into my page.xaml via

    XAMLbitIcon bitIcon = new XAMLbitIcon();
    LayoutRoot.Children.Add(bitIcon); 

    and it works. Could you show how you tried to insert it? 

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Best Regards,
    Johannes

    http://www.irisindividuell.de
    http://www.itecon.de
    http://www.johanneshiemer.de
  • Re: <asp:Silverlight control not rendering all Xaml

    04-08-2008, 11:20 AM
    • Loading...
    • datagrid
    • Joined on 05-23-2007, 1:01 PM
    • USA
    • Posts 461

    johannes.hiemer:

    Hi,

    I used your xaml, and inserted into my page.xaml via

    XAMLbitIcon bitIcon = new XAMLbitIcon();
    LayoutRoot.Children.Add(bitIcon); 

    and it works. Could you show how you tried to insert it? 

     I was using the <asp:Silverlight> control

    Created a Xaml file with the coentent that I posted. then in my aspx page, I have the following

    <asp:Silverlight id="myXaml" runat="Silver" Source="~/Xaml/Button.xaml">

    It did not render.

    Where should we add the following code:? Can we add the following code in our code behind?

    XAMLbitIcon bitIcon = new XAMLbitIcon();
    LayoutRoot.Children.Add(bitIcon); 

     

    Das (http://aspalliance.com/author.aspx?uId=697)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you. This marks your thread as Resolved so we will all know you have been helped.
  • Re: <asp:Silverlight control not rendering all Xaml

    04-08-2008, 11:42 AM

    Hi,

    okay that's some kind of different usage. You are trying to insert it via asp:Silverlight control into a normal aspx-page. I embedded it into a complete Xaml page. Example you can see here: http://dotnet.johanneshiemer.de/wp-content/uploads/SilverlightMenu/Default.html

    So the problem must be connected with the asp:Silverlight-Tag. Actually I never did that so I have to gues: Did you try to insert ScriptType="Classname.Controlname" ?


     

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Best Regards,
    Johannes

    http://www.irisindividuell.de
    http://www.itecon.de
    http://www.johanneshiemer.de
  • Re: <asp:Silverlight control not rendering all Xaml

    04-08-2008, 1:52 PM
    • Loading...
    • datagrid
    • Joined on 05-23-2007, 1:01 PM
    • USA
    • Posts 461

    johannes.hiemer:

    Hi,

    okay that's some kind of different usage. You are trying to insert it via asp:Silverlight control into a normal aspx-page. I embedded it into a complete Xaml page. Example you can see here: http://dotnet.johanneshiemer.de/wp-content/uploads/SilverlightMenu/Default.html

    So the problem must be connected with the asp:Silverlight-Tag. Actually I never did that so I have to gues: Did you try to insert ScriptType="Classname.Controlname" ?

    Did not try the ScriptType property.

    I am puzzled here. I was wondering what would be real use of <asp:Silverlight control then? I was at the impression that the Silverlight control can render any Xaml content. I am missing something here. Not sure what needs to be done in order to render the Xam that I posted my first post using the Silverlight control.

    Thanks. 

     

    Das (http://aspalliance.com/author.aspx?uId=697)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you. This marks your thread as Resolved so we will all know you have been helped.
  • Re: <asp:Silverlight control not rendering all Xaml

    04-08-2008, 3:05 PM

    Hi,

    did you try this one: http://alpascual.com/blog/al/archive/2008/03/20/adding-a-silverlight-user-control-into-a-asp-net-page.aspx

     

    Add the binary on the web.config:
    
    <add tagPrefix="asp" namespace="System.Web.UI.SilverlightControls"
    assembly="System.Web.Silverlight" />
    
    Register the tag:
    
    <%@ Register Assembly="System.Web.Silverlight"
    Namespace="System.Web.UI.SilverlightControls"
       TagPrefix="asp" %>
    
    Register the control
    
    <div  style="height:100%;">
               <asp:Silverlight ID="Xaml1" runat="server"
    Source="~/ClientBin/SilverlightApplication1.xap" Version="2.0"
    Width="100%" Height="100%" />
           </div> 
     
    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Best Regards,
    Johannes

    http://www.irisindividuell.de
    http://www.itecon.de
    http://www.johanneshiemer.de
  • Re: <asp:Silverlight control not rendering all Xaml

    04-09-2008, 9:07 AM
    • Loading...
    • datagrid
    • Joined on 05-23-2007, 1:01 PM
    • USA
    • Posts 461

    Tried this method with no luck. Sill searching google ... 

    johannes.hiemer:

    Hi,

    did you try this one: http://alpascual.com/blog/al/archive/2008/03/20/adding-a-silverlight-user-control-into-a-asp-net-page.aspx

    Add the binary on the web.config:
    
    <add tagPrefix="asp" namespace="System.Web.UI.SilverlightControls"
    assembly="System.Web.Silverlight" />
    
    Register the tag:
    
    <%@ Register Assembly="System.Web.Silverlight"
    Namespace="System.Web.UI.SilverlightControls"
       TagPrefix="asp" %>
    
    Register the control
    
    <div  style="height:100%;">
               <asp:Silverlight ID="Xaml1" runat="server"
    Source="~/ClientBin/SilverlightApplication1.xap" Version="2.0"
    Width="100%" Height="100%" />
           </div> 
     
    Das (http://aspalliance.com/author.aspx?uId=697)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you. This marks your thread as Resolved so we will all know you have been helped.
  • Re: <asp:Silverlight control not rendering all Xaml

    04-16-2008, 10:22 PM

    Maybe this was just a typeo, but you said:

    <asp:Silverlight id="myXaml" runat="Silver" Source="~/Xaml/Button.xaml"/>

    It should be runat="server" not runat="silver". Also, you should specify a Width and Height, lest you will get the default width and height for a plugin in the browser, which is probably not what you wanted:

    <asp:Silverlight id="myXaml" runat="server" Source="~/Xaml/Button.xaml" Width="50px" Height="50px"/>

    And alas, you can use the ScaleMode property to make the xaml fit the width/height of the server control how you want it to. For you, you probably want Stretch, which will make it fill the width and height even if it has to stretch it to do so:

    <asp:Silverlight id="myXaml" runat="server" Source="~/Xaml/Button.xaml" Width="50px" Height="50px" ScaleMode="Stretch" />

    If it is still not rendering its likely something wrong with your XAML or the XAML couldn't be downloaded from the server (due to incorrect path, mime type issue, etc).

    End the confusion.
    Infinities Loop: TRULY Understanding ViewState
    .NET from a new perspective.

    This posting is provided "AS IS".
Page 1 of 1 (8 items)