Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A work round would really depend on why you want to include a raw Guid in Xaml in the first place.</p> <p>You can't use <code>sys:Guid</code> in the way you are attempting to because Xaml has no way to know how to convert the content of the element to an instance of a Guid structure. In fact you can't include an empty <code>sys:Guid</code> although I don't know why you can't do that (not that it would ever be useful to do so anyway).</p> <p>However if you are trying to assign a value to a property on an instance of a type you control then you can work round this with a type converter. First add a <code>GuidConverter</code> to your project:-</p> <pre><code>using System; using System.ComponentModel; using System.Globalization; namespace SilverlightApplication1 { public class GuidConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(string); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { return new Guid((string)value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { return ((Guid)value).ToString("", culture); } } } </code></pre> <p>Now decorate your type's property with a <code>TypeConverter</code> attribute:</p> <pre><code>[TypeConverter(typeof(GuidConverter))] public Guid MyGuidValue {get; set; } </code></pre> <p>Now in your xaml you can do this:-</p> <pre><code>&lt;local:MyType MyGuidValue="F16095D1-1954-4C33-A856-2BDA87DFD371" /&gt; </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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