c# - How to initialize readonly item collection with resource in XAML -
suppose have control readonly items
collection. can initialize collection using collection syntax:
<something> <something.items> <item /> <item /> </something.items> </something>
suppose have collection in resources , want initialize control it:
<window.resources> <itemcollectionclass x:key="collection"> <item /> <item /> </itemcollectionclass> </window.resources>
how it? <something items="{staticresource collection}" />
doesn't work since it's trying set collection instance, not initialize it.
you can initialize collection objectdataprovider:
<window.resources> <itemcollectionclass x:key="collection"> <item /> <item /> </itemcollectionclass> <objectdataprovider x:key="..." objecttype="{x:type local:something}"> <objectdataprovider.constructorparameters> <staticresource resourcekey="collection" /> </objectdataprovider.constructorparameters> </objectdataprovider> </window.resources />
Comments
Post a Comment