Welcome to MSDN Blogs Sign in | Join | Help

Lester's WPF blog


Simple, easy & beautiful

News

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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

           xmlns:sys="clr-namespace:System;assembly=System"

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

      <WrapPanel.Resources>

            <sys:String x:Key="string1">Hello world!! .NET 4 Coming Soon!! New features in WPF!!</sys:String>

      </WrapPanel.Resources>

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

            <FlowDocument>

                  <Paragraph>

                        <Run>Sample Text Beginning:</Run>

                        <TextBlock Text="{StaticResource string1}"></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="{StaticResource string1}" />

                        <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

 

Posted: Wednesday, November 04, 2009 4:03 PM by llester

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker