开发者

XAML text binding

开发者 https://www.devze.com 2023-01-30 14:18 出处:网络
I would bind a string property to text property like this: T开发者_开发问答ext=\"{Binding propertyName}.

I would bind a string property to text property like this: T开发者_开发问答ext="{Binding propertyName}.

I also want to append a hardcoded string to this like Text="{Binding propertyName} appendedName. How to do this?


Text="{Binding propertyName,StringFormat='Your property is: {}{0}'}"


You could use Run Text:

<TextBlock>
<Run Text="{Binding YourBinding}"/>
<Run Text="Suffix"/>
</TextBlock>

If you want to use it like this several times I would recommend a TemplatedControl where you have a Suffix DependencyProperty and a Text DependencyProperty.


You should create new property that returns text + appendedName.
Another way is to use several text blocks.

0

精彩评论

暂无评论...
验证码 换一张
取 消