简体   繁体   中英

XAML collection initialization from WPF custom control

How do I generate some XAML collection items entries just after dropping my WPF custom control on the WPF window surface?

Now, each time I drop it on the window, I need to add items manually typing XAML even if I know in advance I will need at least five of them.

In practice I need to generate additional XAML on my WPF custom control initialization.

Thanks.

I think what you're looking for is DesignData . This allows you to specify design-time data that can be populated in your custom control during the Design Process.

The basic workflow is to create a XAML data context file and add it to your project with the Build Type of DesignData and then to apply the d:DesignData property in the DataTemplate of your custom control.

Good examples of how this works can be found here and here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM