Reputation: 123
is there a posibility to have a label, with a "standart" text AND a binding content? this is what i´m looking for:
<Label Text="Hello, this is {Binding name}"/>
but this doesnt work. i know, i could make it like this:
<Label Text="Hello, this is "/>
<Label Text="{Binding name}"/>
but i would really like to do it in only one label, because if there's a wordwrap, it doesnt look that well.
thanks a lot
Upvotes: 0
Views: 400
Reputation: 833
You should do it in code, so something like this.
private string _name;
public string Name
{
get
{
return String.Format("Hello, this is {0}", _name);
}
set
{
_name = value;
RaisePropertyChanged("Name"); //bear in mind this is depended on MVVM framework you are using
}
}
Upvotes: 1
Reputation: 1108
You can achieve this using FormattedText property on Label
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="Hello, this is ">
<Span Text="{Binding name}">
</FormattedString>
</Label.FormattedText>
</Label>
Upvotes: 1