I'm unable to validate the empty data in the rich textbox using MVVM. Here is my scenario
1.User binds some formatted text to the control,then deletes entire text in it and select save button,now how to validate that the text in the richtextbox is empty or no text.
The other issue is, I am using dataproviders example to bind the formatted text ,I am using MVVM pattern (calling documentcontentchanged event using command) here I'm unable to get the updated content as well as binded content from it when user adds/deletes text.
Below is code i am using
<
UserControl.Resources>
<Htmlprovider:HtmlDataProvider x:Key="htmlprovider" RichTextBox="{Binding ElementName=radRichTextBox}"
Html="{Binding ElementName=txtblkDescformattag, Path=Text, Mode=TwoWay}"/>
</UserControl.Resources>
UI
<telerik:RadRichTextBox x:Name="radRichTextBox" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="DocumentContentChanged">
<cmd:EventToCommand PassEventArgsToCommand="True" Command="{Binding Path=ContentChangedCommand, Mode=OneWay}" CommandParameter="{Binding Path=Docuemnt,ElementName=radRichTextBox,Mode=TwoWay}" />
</i:EventTrigger>
</i:Interaction.Triggers> </telerik:RadRichTextBox>
<
TextBlock Height="20" Width="10" x:Name="txtblkDescformattag" Visibility="Collapsed" Text="{Binding Path=CurrentTicket.TicketDescription,Mode=TwoWay}" />
Command
private RelayCommand<RadDocument> _contentChangedCommand = null;
public RelayCommand<RadDocument> ContentChangedCommand
{
get
{
if (_contentChangedCommand == null)
{
_contentChangedCommand =
new RelayCommand<RadDocument>(doc =>
{
try
{
if (!_ticketModel.IsBusy)
{
//string result= doc.ToString();
IDocumentFormatProvider exporter = new HtmlFormatProvider();
string result;
using (MemoryStream stream = new MemoryStream())
{
exporter.Export(doc, stream);
stream.Seek(0,
SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
}
}
}
catch (Exception ex)
{
// notify user if there is any error
AppMessages.RaiseErrorMessage.Send(ex);
}
});
}
return _contentChangedCommand;
}
}
How to resolve these two issues
Regards,
Nav