Answered Adding a Static Resource to a XAML file

  • Tuesday, July 24, 2012 6:07 PM
     
      Has Code

    Hey, I am trying to bind a Value Converter to a XAML element. I am trying to add this code to my grid:

    <Grid.Resources>
        <local:ValueConverter x:Name="PlayheadConverter/>"
    </Grid.Resources>

    But it doesn't recognize ValueConverter as a valid class to insert there. Here is my ValueConverter declaration:

    public ref class ValueConverter sealed : Windows::UI::Xaml::Data::IValueConverter
        {
        public:
            ValueConverter(void);
            virtual Object^ Convert(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
    	virtual Object^ ConvertBack(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
        };

    Is there something else I should be doing? I don't understand why I can't add this as a static resource here. Thanks so much!

All Replies

  • Wednesday, July 25, 2012 1:32 AM
    Moderator
     
     Answered

    Is ValueConverter defined in a namespace different than the XAML? (I'm assuming the close quote placement was a typo in the forum post) The XAML Data binding sample demonstrates in the Scenario2.XAML what you are attempting.

    What error are you getting?


    David Lamb

  • Thursday, July 26, 2012 11:02 PM
     
     
    Somehow I seem to have lost this file, but I am now experiencing another issue you may be able to help me with. Is it possible to use a Value Converter that does not have a default constructor?