How can I prefix related values ββin TextBlock controls in a StackPanel without using separate controls for prefixes?
For example, let's say I have a dialog that uses TreeView to display a list of books, with the top nodes being the title and a set of subordinate nodes for other attributes of the book (ISBN, Author, etc.).
I have a binding that works correctly, but my user wants the list of book attributes to stack vertically, and obviously he wants each node attribute to have a descriptive prefix before the value (for example, "Author: Erich Gamma") and not just " Erich Gamma "). Inside my HDT and DT elements, I use the StackPanel and TextBlock elements to display the values.
Should I use a separate TextBlock control to prefix each attribute
<TextBlock Text="Author: "/><TextBlock Text="{Binding Path=Author}" />
or is there a way to do this with a single TextBlock control for each node?
<TextBlock Text="Author: {Binding Path=Author}" />
I know this should be a common problem, and I Googled for it and looked in my three WPF books, but I think I donβt know how to correctly search for what I'm trying to say.
Thank!
source
share