New WPF Features: Bindable Run

This is part of a series on New WPF Features

Bindable run - yeah its possible currently but you would require a custom implementation. if you didnt like to create your own implementation, likely you would be using textblock. Problem here is that its likely you would have issues in copy paste scenarios, layout and what not. Now its a lot easier as the framework supports it.

<WrapPanel xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" >

<TextBlock Text='Hello world!! .NET 4 Coming Soon!! New features in WPF!!' Visibility='Collapsed' Name='tbl'></TextBlock>

<FlowDocumentReader Width="350" BorderBrush="red" BorderThickness="3" Height="150">

<FlowDocument>

<Paragraph>

<Run>Sample Text Beginning:</Run>

<TextBlock Text="{Binding ElementName='tbl',Path=Text}></TextBlock>

<Run>End of sample text.</Run>

</Paragraph>

</FlowDocument>

</FlowDocumentReader>

<FlowDocumentReader Width="350" BorderBrush="red" BorderThickness="3" Height="150">

<FlowDocument>

<Paragraph>

<Run>Sample Text Beginning:</Run>

<Run Text="{Binding ElementName='tbl',Path=Text}" />

<Run>End of sample text.</Run>

</Paragraph>

</FlowDocument>

</FlowDocumentReader>

</WrapPanel>

 

Difference is obvious.. in the textblock case you have wider separations, text is clipped.... look to the right.. its perfect :)

 

 

Share this post