开发者

Binding with custom text in WPF

开发者 https://www.devze.com 2022-12-31 04:51 出处:网络
Can i write something like this in WPF(i know that this piece of code is wrong, but need to know if there is kind of this construct):

Can i write something like this in WPF(i know that this piece of code is wrong, but need to know if there is kind of this construct):

<TextBlock Height="50" Text="Test: {Binding Path=MODULE_GUID}" />

Or always to add some text to binding value i must do something like this:

<StackPanel Orientation="Horizontal"&g开发者_JAVA技巧t;
   <TextBlock Height="50" Text="Test: " />
   <TextBlock Height="50" Text="{Binding Path=MODULE_GUID}" />
</StackPanel>


Starting with .NET 3.5 SP1, you can use:

<TextBlock Height="50" Text="{Binding Path=MODULE_GUID, StringFormat='Test: {0}'}" />


You can use StringFormat in the Binding


Simply use string format in Binding

<TextBlock Text="{Binding Path=MODULE_GUID, StringFormat='Your Text Goes Here {0}'}" />

Remember {0} must be there.

0

精彩评论

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