Several Issues

9 posts, 0 answers
  1. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 21 Sep 2010 Link to this post

    Hi,

    I'm trying to use the RichTextBox in my application. Scenario is complex, it's a prism application. The RichTextBox is injected at runtime and I'm facing several matters:
    1. I'd like to usus RadRichTextBoxRibbonBarUI and autogenerate the xaml for the RIbbons bar. But it's not workin for me. I'm using 2010 Q2 Sp1 telerik version and Visual Studio 2010 Utlimate Edition. I can't drop any telerik control on the Visual Studio's design surface, so RadRichTextBoxRibbonBarUI can't be autogenerated.
    2. It's being hard to me to perform Data binding in RichTextBox. I'm adopting MVVM pattern. The RichTextBox should be bound to a Text Property (string) in my MVVM object. I need the formatted Text and also the plain text in richTextBox as this text must be inserted in a database and other application must acces to the palin text property. 
    3. The most important. I'm having a System Unauthorized Exception when view with the RichTextBox control is injected. It's related with a cross thread operation. Entire Exception message is: 
      Error en tiempo de ejecución de Microsoft JScript: Unhandled Error in Silverlight Application Acceso entre procesos no válido.   a MS.Internal.XcpImports.CheckThread()
         a System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)
         a Telerik.Windows.Documents.Model.DocumentElement..ctor()
         a Telerik.Windows.Documents.Model.Paragraph..ctor()
         a Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverride(SizeF availableSize)
         a Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize)
         a Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize)
         a Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
         a Telerik.Windows.Documents.Layout.DocumentLayoutBox.ArrangeTask.ArrangeCallback(Object state)
         a System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
         a System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
         a System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
         a System.Threading.ThreadPoolWorkQueue.Dispatch()
         a System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

  2. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 22 Sep 2010 Link to this post

    I uninstalled Silverlight teleik controls,then reset the Toolbox in VS 2010 and reinstalled the telerik controls and magically issues 1 and thre desappeared. 

    Now, it only rests issue #2, just a funcionality question. I'll try to explain my scenario. I'm providing a new UI for a kind of appointment management. Till now, our data base contained a plain text field for the appointment. Currently I have added a new database field called FormattedText. My new silverlight application must supply fincionaliy to add new appointments and view stored appointments. When a new appointment is created i need to provide two fields, PlainText and FormattedText, so the old system can continue showing new appointments and Silverilght application may show formatted text. So my VM object needs to provide two properties, PlainText and FormattedText, and I'd like to bind them to the RichTextBox text. In appointmet viewer, my VM class also has the same two properties, PlainText wil always exist but FormattedText may be empty (it can be an appointment inserted from the old system) so I'd like to feed a read only RichTextBox with either FormattedTextBloc (if exists) or Plain Text. 

    Any help with tihs scenario?
  3. DevCraft banner
  4. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 23 Sep 2010 Link to this post

    Hello Daní,

    I am pleased to hear you have resolved most of the issues yourself.
    As for the remaining question, I'd recommend you read the following article: http://www.telerik.com/help/silverlight/radrichtextbox-how-to-binding-to-data-providers.html . It should make things a lot more clear in regards to binding to various fields. Of your particular interest should be TxtDataProvider (mind that we had issues with it, but it will be fixed in the next LIB) and XamlDataProvider, as XAML is the preferred format when persisting RadDocuments. No matter which data provider you use, the content always ends up as RadDocument, so you can use a regular RadRichTextBox no matter what is the format on the other end (plain text, XAML or any other supported format).

    Sincerely yours,
    Ivailo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 23 Sep 2010 Link to this post

    Hi Ivailo,

    I'm trying to bind text from richTextBox, I just reproduced the example in the article you suggested and I'm getting the next exception;
    The type 'XamlDataProvider' was not found because 'clr-namespace:Telerik.Windows.Documents.FormatProviders.Xaml;assembly=Telerik.Windows.Documents.FormatProviders.Xaml' is an unknown namespace. [Line: 9 Position: 115]

    Code snippet:
    <UserControl
        xmlns:documentsXaml="clr-namespace:Telerik.Windows.Documents.FormatProviders.Xaml;assembly=Telerik.Windows.Documents.FormatProviders.Xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="UIAssistencial.Pacient.CursClinic.EditorCurs.MainPage"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
        <UserControl.Resources>
            <documentsXaml:XamlDataProvider x:Key="xamlProvider" RichTextBox="{Binding ElementName=richTextBox}" Xaml="{Binding ElementName=textBox, Path=Text, Mode=TwoWay}"/>
        </UserControl.Resources>
      <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
            <TextBox x:Name="textBox" HorizontalAlignment="Stretch"></TextBox>
            <telerik:RadRichTextBox x:Name="richTextBox" Grid.Row="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
        </Grid>
    </UserControl>

    Maybe I'm missing to reference an assembly. My project is referencing next telerik dll:
    Telerik.Windows.Controls
    Telerik.Windows.Controls.Data
    Telerik.Windows.Controls.Input
    Telerik.Windows.Controls.Navigation
    Telerik.Windows.Controls.RibbonBar
    Telerik.Windows.Controls.RichTextBoxUI
    Telerik.Windows.Data
    Telerik.Windows.Documents
    Telerik.Windows.Documents.FormatProviders.Xaml
  6. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 23 Sep 2010 Link to this post

    Hello Daní,

    Your references are actually correct, however note that the data providers were introduced with 2010 Q2 SP1, so please make sure you have referenced the correct version of Telerik.Windows.Documents.FormatProviders.Xaml.dll. You can also double click the assembly reference inside Visual Studio which will open the Object Browser. This way you can check if the version you're using actually contains the class (Telerik.Windows.Documents.FormatProviders.Xaml.XamlDataProvider).
    Feel free to get back if your problems persist.

    Best wishes,
    Ivailo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 23 Sep 2010 Link to this post

    I could solve issue, I'm using Prism in my application and the RixhTextBox is in a view in a module. Adding Documents.dll and Documents.FormatProviders.xaml to the main project (the one containing the Shell) solve the problem.

    Now, I'm facing a new issue. I'm binding the XamlDataProvider Xaml property to the XamlText property in my ViewMode object. This is a TwoWay binding, but XamlText value is never set while writing on RichTextBox. When data from RichTextBox is update to DataContext source?
  8. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 28 Sep 2010 Link to this post

    Hi Daní,

    The XamlDataProvider works exactly as shown in the demo:
    http://www.telerik.com/help/silverlight/radrichtextbox-features-data-providers.html
    Did you make sure to set the RichTextBox property of the XamlDataProvider to the RadRichTextBox you are using? I am attaching a demo where you can see live two-way binding between a TextBox and a RadRichTextBox. Hopefully that helps you solve your issue.

    Sincerely yours,
    Iva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Karlkim Suwanmongkol
    Karlkim Suwanmongkol avatar
    41 posts
    Member since:
    Aug 2012

    Posted 28 Jan 2011 Link to this post

    Hi Telerik,
       I download the 350334-351872-radrichtextboxtwowaybinding.zip and play with it. However, I couldn't figure out what XamlProvider expects from me. I put simple XAML like "<TextBlock>TEST</TextBlock>", and the RadRichTextBox does not display anything. Could you provide me some XAML example that will work with your demo?

    I am using Telerik Silverlight, 2010.3.1110.1040.

    I attach a screenshot in case you don't know what I am talking about.
  10. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 31 Jan 2011 Link to this post

    Hello Karlkim Suwanmongkol,

    XAML is a language designed to represent objects in a generic way. "<TextBlock>TEST</TextBlock>" interpreted as XAML is just a TestBlock. What the XAML of RadRichTextBox is representing is a RadDocument instance. Therefore, here's how a sample RadDocument XAML might look like:
    <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.0" DefaultPageLayoutSettings="800,1140" LayoutMode="Paged" PageViewMargin="10,10">
      <t:Section>
        <t:Paragraph>
          <t:Span Text="test xaml" />
        </t:Paragraph>
      </t:Section>
    </t:RadDocument>
    This XAML will be correctly imported by XamlFormatProvider.

    Kind regards,
    Ivailo
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top
DevCraft banner