Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes. The WPF binding system will use a <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.customtypedescriptor.aspx" rel="nofollow">custom type descriptor</a> to interact with the properties of your ViewModel at runtime. I've used this before to make keys in a KeyValueCollection&lt;T> appear as properties on the collection.</p> <p><strong>This has two important benefits.</strong> It simplifies binding:</p> <p><code>DataContext.SomeCollectionProperty[SomeKey]</code> can be simplified to <code>DataContext.SomeCollectionProperty.SomeKey</code> and, if you make a custom type descriptor for the data context, <code>DataContext.SomeKey</code> which is about as simple as it gets.</p> <p><strong>And it fixes what I consider a bug</strong>--format strings are rendered even when the property is null. Using a CTD, you can skip null (and DBNull) properties, ensuring that format strings won't be rendered if the property doesn't exist:</p> <p>Imagine you have a <code>double?</code> that you must render as a dollar amount. If you use the following binding: <code>{Binding Price, FormatString='Price: {0:c}'}</code> and the Price is null, you get the following in your UI: <code>Price: $</code>. This is ugly. However, if <code>Price</code> is a PropertyDescriptor-based property on your UI, when the Price is null, you can opt to not to report this property via your CTD. This prevents the format string from being rendered at all.</p> <p>Here's a pretty good link at MSDN about <a href="http://msdn.microsoft.com/en-us/library/ms171819.aspx" rel="nofollow">decorating your types with a CTD</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload