In the previous question, I was trying to figure out how to bind an ObservableCollection to a control so that I can see all the rows and select all the rows and copy them from the content control. The answers to this question eventually made me look (and it seems the behavior) that I wanted using the following XAML. (I tried both FlowDocumentReader and FlowDocumentScrollViewer - they behave the same.)
<Grid> <FlowDocumentScrollViewer> <FlowDocument > <Paragraph> <ItemsControl ItemsSource="{Binding ErrorMessages, Mode=OneWay}" /> <Run Text="{Binding /, Mode=OneWay}" /> </Paragraph> </FlowDocument> </FlowDocumentScrollViewer> </Grid>
ErrorMessages is my ViewModel property, which returns an ObservableCollection <string> . It is bound correctly to the ItemsSource , and the <Run> element is bound to every row in the collection. It looks good, lasts a long time. It was so close that I answered the last question, but I still have one problem.
I right-click and a menu appears with the options "Select All" and "Copy". Using Select All, it really selects all the text, choosing Copy Problems, there are no errors, but when I go to NotePad (or Word, or TextPad, etc. Or RTB in the form) and try to paste the text, nothing appears . As a newbie to WPF, I suspect I'm doing something wrong, but I don't know what it is. There is no such thing as a "carefree" text?
[Edit -June 22 2011] For other reasons, I changed the code to use the TextBlock via the ItemTemplate inside the ItemsControl, as shown below, but I still can not copy and paste.
<DataTemplate x:Key="StringCollection"> <TextBlock TextWrapping="Wrap" Text="{Binding}" TextAlignment="Left"/> </DataTemplate> <ItemsControl ItemsSource="{Binding ReceivedData, Mode=OneWay}" ItemTemplate="{StaticResource StringCollection}" />