Reputation: 1586
I would like to implement a multi binding for the header of my group box.
This is my current approach:
<GroupBox>
<GroupBox.Header>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}My Custom Header - {0}">
<Binding Path="VM.Obj1.Obj2.PropertyName"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</GroupBox.Header>
</GroupBox>
If I implement it in this way, the header of my group box shows System.Windows.Controls.TextBlock
What is the correct way to use multi binding for the header of my group box so that the Text Block uses multi binding and binds to my strig property "PropertyName"? So the result shall be:
My Custom Header - StringValueOfPropertyName
Upvotes: 0
Views: 905
Reputation: 21261
You don't need a multibinding when there's only one binding:
<GroupBox>
<GroupBox.Header>
<TextBlock Text="{Binding VM.Obj1.Obj2.PropertyName, StringFormat=My Custom Header - {0}}"/>
</GroupBox.Header>
</GroupBox>
In fact GroupBoxHeader allows string format directly using HeaderStringFormat:
<GroupBox Header="{Binding VM.Obj1.Obj2.PropertyName}"
HeaderStringFormat="My Custom Header - {0}" />
Upvotes: 3