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

Use own commands in RadRichTextBox

1 Answer 98 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Nelson
Top achievements
Rank 1
Nelson asked on 11 Aug 2011, 12:44 PM
Hi there,

I use the RadRichTextBox and I need the DocumentChanged event in my ViewModel.

Fisrt I try use command but the RadRichTextBox control doesn´t support that, only use RadRichTextBox"Commands"!

After that, I try use Triggers and InvokeDataCommand, like this:
<Grid Name="grdWord" Width="Auto" Grid.Row="1">
                  <!--<TextBlock Text="{Binding Path=ConteudoTemplate,ElementName=PrevisualizarTemplate}"/>-->
                  <!--<UC:SGAControloWord HorizontalAlignment="Center" VerticalAlignment="Bottom" Height="Auto" Margin="0,40,0,10"/>-->
                  <Grid Height="450">
                      <Grid.RowDefinitions>
                          <RowDefinition Height="Auto"/>
                          <RowDefinition Height="*" />
                          <RowDefinition Height="Auto" />
                      </Grid.RowDefinitions>
                      <telerikHtml:HtmlDataProvider x:Name="HtmlProvider" RichTextBox="{Binding ElementName=radRichTextBox1}" Html="{Binding Path=ConteudoTemplate,ElementName=PrevisualizarTemplate, Mode=TwoWay}"/>
                      <telerik:RadRichTextBox Grid.Row="1" HorizontalAlignment="Left" Margin="40 0 0 0" IsContextMenuEnabled="True" IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="True" LayoutMode="Flow" Width="550" Name="radRichTextBox1" VerticalAlignment="Stretch" telerik:StyleManager.Theme="Summer">
                          <swi:Interaction.Triggers>
                              <swi:EventTrigger EventName="DocumentChanged">
                                  <esi:InvokeDataCommand Command="{Binding Path=ComandoSeleccao, Source={StaticResource VisualizaNotificacoesVM}}"/>
                              </swi:EventTrigger>
                          </swi:Interaction.Triggers>
                      </telerik:RadRichTextBox>
in my  ViewModel I have This in constructor:
_comandoSeleccao = new RelayCommandOriginal(TESTECOMANDO);


And the method that I want put my logic for when event fired:


private void TESTECOMANDO(object sender)
{
MessageBox.Show("Hello");
}


Nothing...I can´t catch the event on ViewModel.

Any help please?

Thanks

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 16 Aug 2011, 04:26 PM
Hello Nelson,
I am not sure what is the implementation of the trigger action InvokeDataCommand that you are using, but please find attached a working demo using the Expression Blend SDK's InvokeCommandAction.
<telerik:RadRichTextBox Name="radRichTextBox">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="DocumentChanged">
            <i:InvokeCommandAction Command="{Binding MessageBoxCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</telerik:RadRichTextBox>

Don't hesitate to contact us if you have other questions.


All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
RichTextBox
Asked by
Nelson
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or