Changing the path a property is bound to at runtime
I have a ComboBox 开发者_运维知识库with a list of objects bound to it. Currently i have the items templated so they show only the property Class.Name. so the ComboBox is full of Class.Name However i am required to give the user the option to display the property Class.Description instead. If it were just that easy i would be fine, but they want the option to switch back and forth between them at runtime.
Any ideas?
You can probably do this directly in WPF.
I would alter the business objects to include an additional Readonly property, something like, DisplayTextProperty
Public ReadOnly Property DisplayTextProperty()
Get
If ShowDescription Then
Return Description
Else
Return Name
End If
End Get
End Property
I have done this in a few places now and it works great.
精彩评论