0

How can I use ContentPropertyAttribute with C++/WinRT? I find some help in github and msdn,
but regretfully when I code like this

namespace App3
{
    [bindable]
    [default_interface] 
    [Windows.UI.Xaml.Markup.ContentPropertyAttribute("Actions")]
    runtimeclass EventBehavior : Windows.UI.Xaml.DependencyObject, Microsoft.Xaml.Interactivity.IBehavior
    {
        EventBehavior(); 

        static Windows.UI.Xaml.DependencyProperty SourceObjectProperty{ get; };

        Object SourceObject{ get; set; };

        static Windows.UI.Xaml.DependencyProperty EventNameProperty{ get; };

        String EventName{ get; set; };

        static Windows.UI.Xaml.DependencyProperty ActionsProperty{ get; };

        Microsoft.Xaml.Interactivity.ActionCollection Actions{ get; };
    }
}

it doesn't compile. The error is

MIDL2009  [msg]undefined symbol [context]: Windows.UI.Xaml.Markup.ContentPropertyAttribute 
    BlankApp4   C:\Users\Cool-\source\repos\BlankApp4\BlankApp4\EventBehavior.idl   

So, my question is how to use ContentPropertyAttribute?

Cool
  • 23
  • 5
  • Did you read [Troubleshooting Microsoft Interface Definition Language 3.0 issues](https://learn.microsoft.com/en-us/uwp/midl-3/troubleshooting)? – IInspectable Feb 02 '20 at 07:52
  • thankes, but your link doesn't help me. The error is error MIDL2009: [msg]undefined symbol [context]: Windows.UI.Xaml.Markup.ContentPropertyAttribute, remove "[Windows.UI.Xaml.Markup.ContentPropertyAttribute("Actions")]" it will compile. and my question is how to use ContentPropertyAttribute. – Cool Feb 02 '20 at 08:48
  • I forget to say that my dev tools is Visual Studio 2019 16.4 – Cool Feb 02 '20 at 08:53
  • The link explains certain conditions that trigger MIDL2009. It depends on how you run midl.exe (or midlrt.exe), as well as whether or not you are `import`ing other IDL's. You should at least make sure to address that in the question by explaining, how you are running midl.exe, as well as the full, minimal IDL file you are compiling. – IInspectable Feb 02 '20 at 09:03
  • ok, the post has been updated – Cool Feb 02 '20 at 09:16
  • As explained in the first link you posted, `ActionsProperty` needs to be `static`. This may or may not be related to your issue. – IInspectable Feb 02 '20 at 10:01
  • 2
    I got the solution by view win ui source code. actually, it should be like this ```[contentproperty("ItemTemplate")]``` – Cool Feb 04 '20 at 03:27

0 Answers0