This question is locked. New answers and comments are not allowed.
I have XAML data which was generated by splitting up a single Word document into multiple RadDocuments (using manual page breaks) which were then exported seperate XAML documents (in byte arrays). I then try and dynamically load these XAML byte[] into a RadRichTextBox only to have nothing displayed and no changes written back to the byte array when edited in the editor.
XAML:
Code behind:
RadDocument XAML passed in:
What am I doing wrong?
Note:- It works fine if populated by setting the Document property to the output of XamlFormatProvider.Export(byte[]).
XAML:
<controls:ChildWindow x:Class="CMSPrototype.Controls.TestWindow" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:telerikXAML="clr-namespace:Telerik.Windows.Documents.FormatProviders.Xaml;assembly=Telerik.Windows.Documents.FormatProviders.Xaml" Width="400" Height="300" Title="TestWindow" x:Name="testWindow"> <controls:ChildWindow.Resources> <!-- Telerik Data Provider --> <telerikXAML:XamlDataProvider x:Key="xamlDataProvider" RichTextBox="{Binding ElementName=editor}" Xaml="{Binding Path=CurrentDocument, ElementName=testWindow, Mode=TwoWay}" SetupDocument="XamlDataProvider_SetupDocument"/> </controls:ChildWindow.Resources> <Grid x:Name="LayoutRoot" Margin="2"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <telerik:RadRichTextBox Name="editor" /> <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" /> <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" /> </Grid></controls:ChildWindow>Code behind:
using System.Windows;using System.Windows.Controls;using Telerik.Windows.Documents.Model;using Telerik.Windows.Documents.FormatProviders.Xaml;namespace CMSPrototype.Controls{ public partial class TestWindow : ChildWindow { public static readonly DependencyProperty CurrentDocumentProperty = DependencyProperty.RegisterAttached( "CurrentDocument", typeof(byte[]), typeof(TestWindow), null ); public byte[] CurrentDocument { get { return (byte[])GetValue(CurrentDocumentProperty); } set { SetValue(CurrentDocumentProperty, value); } } public TestWindow(byte[] currentDocument) { this.CurrentDocument = currentDocument; InitializeComponent(); } private void OKButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = true; } private void CancelButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = false; } private void XamlDataProvider_SetupDocument(object sender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e) { } }}RadDocument XAML passed in:
<t:RadDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" version="1.1" DefaultPageLayoutSettings="793.7333,1122.533" LayoutMode="Paged" PageViewMargin="10,10" SectionDefaultPageMargin="95,95,95,95"> <t:Section PageMargin="120,96,120,96"> <t:Paragraph FontSize="13.3333330154419" SpacingAfter="0" /> <t:Paragraph SpacingAfter="0"> <t:Span FontFamily="Times New Roman" FontSize="16" FontWeight="Bold" Text="All You Need Is Love Lyrics" UnderlineColor="#FF000000" UnderlineDecoration="None" /> <t:Span FontFamily="Times New Roman" FontSize="16" Text="¬Artist(Band):" UnderlineColor="#FF000000" UnderlineDecoration="None" /> <t:Span FontFamily="Times New Roman" FontSize="16" FontWeight="Bold" Text="The Beatles" UnderlineColor="#FF000000" UnderlineDecoration="None" /> <t:Span FontFamily="Times New Roman" FontSize="16" Text=" " UnderlineColor="#FF000000" UnderlineDecoration="None" /> </t:Paragraph> <t:Paragraph SpacingAfter="0"> <t:Span FontFamily="Times New Roman" FontSize="16" Text="Love, Love, Love.¬Love, Love, Love.¬Love, Love, Love.¬¬There's nothing you can do that can't be done.¬Nothing you can sing that can't be sung.¬Nothing you can say but you can learn how to play the game.¬It's easy.¬¬Nothing you can make that can't be made.¬No one you can save that can't be saved.¬Nothing you can do but you can learn how to be you in time.¬It's easy.¬¬All you need is love.¬All you need is love.¬All you need is love, love.¬Love is all you need.¬¬All you need is love.¬All you need is love.¬All you need is love, love.¬Love is all you need.¬¬Nothing you can know that isn't known.¬Nothing you can see that isn't shown.¬Nowhere you can be that isn't where you're meant to be.¬It's easy.¬¬All you need is love.¬All you need is love.¬All you need is love, love.¬Love is all you need.¬¬All you need is love (All together, now!)¬All you need is love. (Everybody!)¬All you need is love, love.¬Love is all you need (love is all you need)¬(love is all you need) (love is all you need) ¬(love is all you need) Yesterday (love is all you need)¬(love is all you need) (love is all you need)¬¬Yee-hai!¬Oh yeah!¬love is all you need, love is all you need,love is all you need, love is all you need, oh yeah oh hell yea! love is all you need love is all you need love is all you need." UnderlineColor="#FF000000" UnderlineDecoration="None" /> </t:Paragraph> </t:Section></t:RadDocument>What am I doing wrong?
Note:- It works fine if populated by setting the Document property to the output of XamlFormatProvider.Export(byte[]).