Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert WPF XAML to Silverlight XAML
    primarykey
    data
    text
    <p>I have question about using XAML across the WPF and Silverlight platforms.</p> <p>Background:</p> <p>I have a silverlight app that needs to pass the Xaml to WPF and do some calculation to update the XAML. When I run the changes in WPF, I parse the XAML and convert it to the Canvas object which does the job perfectly fine. The problem is WPF strip out the silverlight namespace and even delete the name of some elements.</p> <p>The code that I use to convert XAML into Canvas</p> <pre><code>Canvas canvas = XamlReader.Parse(xaml) as Canvas </code></pre> <p>Here is the original Xaml from Silverlight:</p> <pre><code>&lt;Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="Holder" Width="58" Height="23" &gt; </code></pre> <p> .......</p> <p>After I convert it to a Canvas object, the Xaml of the Canvas become this:</p> <pre><code>&lt;Canvas Name="Holder" Width="58" Height="23" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt; &lt;Canvas.Clip&gt;&lt;RectangleGeometry RadiusX="0" RadiusY="0" Rect="0,0,58,23"/&gt; &lt;/Canvas.Clip&gt;&lt;Rectangle Name="HolderBackground" Canvas.Top="0.4" Canvas.Left="0.4" Width="57.2" Height="22.2" RadiusX="0" RadiusY="0" Fill="#FFFFFF" /&gt; &lt;Canvas Name="Image1" Canvas.Top="0.8" Canvas.Left="0.8" Width="24.37999153137207" Height="21.4"&gt; ....... </code></pre> <p>You should notice the xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" is missing. Also, all the x:Name now becomes Name. If you look closely, you will notice this element's name has been removed </p> <p>Does everyone have any idea or simple solution that I can convert Silverlight XAML -> WPF XAML ->(back to) Silverlight XAML?</p> <p>Cheers </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload