Hi
I have a XamDataGrid which I want to bind to a custom collection exposed by my view model. This works fine at runtime if I specify my binding in the usual way (DataSource="{Binding Path=MyCollection}"), but this doesn't give me any design-time indication of the column layout.
I can get my columns to appear at design time by specifying the datasource collection type like so:
<Custom:XamDataGrid.DataSource> <data:MyCollectionType xmlns:data="clr-namespace:MyNamespace" /></Custom:XamDataGrid.DataSource>
However, then I can't declare my binding in XAML, as the designer complains that the DataSource is set more than once.
I can get around this by resetting the DataSource in code, but I'd prefer to keep everything declarative... Can it be done?
Engaging with UI UX design companies is pivotal for businesses aiming to create exceptional digital experiences. These companies specialize in crafting user interfaces and experiences that are both visually appealing and highly functional, ensuring maximum user satisfaction and engagement. They employ a wide range of design techniques, including user research, prototyping, and testing, to create interfaces that meet the needs of users and drive business results. Partnering with a UI UX design company provides businesses with access to top talent and expertise in the field, ensuring that their digital products stand out in a competitive market.
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Hi Stefan
Thanks for your reply. It seems that the key things are to ensure that the design-time data context is set to the view model using d:DataContext (where xmlns:d="http://schemas.microsoft.com/expression/blend/2008"), and that the view model returns a collection by default... My view model was originally not returning a collection by default, because it loads data asynchronously - having changed that to return an empty collection (and setting the design-time data context) it now works.
Many thanks for your help.
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I set the design DataContext of the XamDataGrid to a mock collection, so the items can be generated in the designer. I also put a second grid where you can see how to define everything in XAML and have a designer. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.