How can use this text value?
Text="My custom text: {Binding MyData}"
In this code?
<TextBlock x:Name="lbl_data" Foreground="Black" TextWrapping="Wrap"
Margin="50,39,130,0" 开发者_StackOverflowFontSize="13.333" FontFamily="Segoe WP Light"
VerticalAlignment="Top" Height="26"
Text="My custom text: {Binding MyData}"
/>
thanks.
Use run:
<TextBlock x:Name="lbl_data" Foreground="Black" TextWrapping="Wrap"
Margin="50,39,130,0" FontSize="13.333" FontFamily="Segoe WP Light"
VerticalAlignment="Top" Height="26"
ext="My custom text: {Binding MyData}">
<TextBlock.Text>
<Run Text="My custom text:" />
<Run Text="{Binding MyData}" />
</TextBlock.Text>
You can write a Converter and pass in the Parameter MyData
If it was Silverlight 4.0 you can inherently use Value Converter like this
<Button Content={Binding MyData, StringFormat='My Custom Text \{0\}'}/>
Also Refer Question : Binding with StringFormat on Windows Phone 7?
The question is quite old, but since I was looking for a similar solution I will post my answer too.
I didn't want to use a converter and I'm using .NET 4.5 with WPF - so it doesn't really apply to the original question. <Run></Run>
did work for me as mentioned in the question above
<TextBlock x:Name="lbl_data" Foreground="Black" TextWrapping="Wrap"
Margin="50,39,130,0" FontSize="13.333" FontFamily="Segoe WP Light"
VerticalAlignment="Top" Height="26"/>
<Run Text"My custom text: "/>
<Run Text="{Binding Path=MyData}"/>
</TextBlock>
精彩评论