How do I get the XAML comiler to use textual content property on custom classes?

Posted by Duncan on Stack Overflow See other posts from Stack Overflow or by Duncan
Published on 2010-03-22T23:24:17Z Indexed on 2010/03/22 23:31 UTC
Read the original article Hit count: 308

Filed under:
|

Given a simple C# class definition like:

    [System.Windows.Markup.ContentProperty("PropertyOne")]
    public class SimpleBase
    {
        public string PropertyOne { get; set; }
        public string PropertyTwo { get; set; }
    }

why is it not possible to ommit the sys:string tags around the word Test in the xaml below.

<custom:SimpleBase x:Class="TestType"
                        xmlns:custom="clr-namespace:ConsoleApplication1;assembly="
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:sys="clr-namespace:System;assembly=mscorlib">
        <sys:String>Test</sys:String>
</custom:SimpleBase>

Somehow the compiler correctly coverts text to string for the type String, why doesn't it work for my custom type?

The context can be found on my blog: http://www.deconflations.com/?tag=xaml

© Stack Overflow or respective owner

Related posts about xaml

Related posts about c#