How to set TypeConverter to attached dependency property in Silverlight?

My goal is to write this in XAML:

<Grid>
    <Rectangle Fill="AliceBlue"
            myCore:MyTimePanel.BeginningDate="03/03/2010"
            />
</Grid>

Problem: Silverlight XAML cannot parse a DateTime from a string. Therefore, at runtime, I have a XamlParseException exception "cannot create DateTime from this string".

When I use a simple DependencyProperty, I just add TypeConverterAttribute to getter / setter and it works. Like this (idea here ):

[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime MyDate
{
    get { return (DateTime)GetValue(MyDateProperty); }
    set { SetValue(MyDateProperty, value); }
}

But with DP attached , there is no getter / setter. What can I do to write string date in XAML?

Thank!

+5
1

Access accessor - Access accessor?

, , . :

3. TypeConverter , . . . TypeConverters XAML.

4. TypeConverter Get accessor. . TypeConverterAttribute Get accessor, Set accessor , , XAML- ( ) . . TypeConverters XAML.

+5

All Articles