This is a migrated thread and some comments may be shown as answers.

Prism and RichTextBox

1 Answer 110 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Joe Lozina
Top achievements
Rank 1
Joe Lozina asked on 17 Nov 2010, 04:53 AM
Hi
I'm trying to bind a RichTextBox to a String that is in a application using the Prism framework.

The Xaml is
<UserControl x:Class="MaintenancePlanner.View.FormView.Log"
    xmlns:Commands="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism"
             xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
             xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
             xmlns:telerikEditor="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents"
             xmlns:telerikXaml="clr-namespace:Telerik.Windows.Documents.FormatProviders.Xaml;assembly=Telerik.Windows.Documents.FormatProviders.Xaml"
             Width="auto" Height="auto">
 
    <UserControl.Resources>
        <telerikXaml:XamlDataProvider x:Key="xamlDataProvider"
                    Xaml="{Binding Path=SelectedLog.LogContent, Mode=TwoWay}"
                                              RichTextBox="{Binding ElementName=editor}"
                                      />
    </UserControl.Resources>
 
     
    <Grid x:Name="LayoutRoot" Background="White" Margin="0 0 0 0" ShowGridLines="False">
...................
 
        <telerikEditor:RadRichTextBox x:Name="editor" Grid.Row="1" Grid.Column="1"/>
         
.............
 
    </Grid>
 
</UserControl>


SelectedLog is the object and LogContent is the variable which is a String.
Its defined in the ViewModel.

private ItemLog _selectedLog;
    public ItemLog SelectedLog
    {
        get
        {
            return this._selectedLog;
        }
        set
        {
            if (value != this._selectedLog)
            {
                this._selectedLog = value;
                this.RaisePropertyChanged(() => this.SelectedLog);
 
                _selectedLog.PropertyChanged += (s, e) =>
                {
                    if (SubmitChangesCommand != null)
                        SubmitChangesCommand.RaiseCanExecuteChanged();
                    CancelLogCommand.RaiseCanExecuteChanged();
                };
            }
        }
    }


Initially the problem I got was
System.Windows.Markup.XamlParseException occurred
  Message=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: 14 Position: 59]

but when I added Telerik.Windows.Documents.FormatProviders.Xaml dll to the main Prism app project(ie the project with the Shell and bootstrapper) that error went away. Id prefer not to add the Dll to that project as it doesnt the reference.

Now I get the following error
System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  InnerException:

Can you tell me how to fix this?

Regards,
Joe






1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 18 Nov 2010, 05:11 PM
Hello Joe Lozina,

The way I see it, you need to have a reference to the binaries in the main project (the one with the Bootstrapper).
As for the System.AccessViolationException, are you getting it before adding the reference or even after that?
There is an article about this exception here. If you do not find the answer there, it would be greatly appreciated if you could send a sample demo, in which the problem is illustrated.


All the best,
Iva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Joe Lozina
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or