This question is locked. New answers and comments are not allowed.
hi,
I want to open docx, txt, html file in my project,
for html file and txt file i have done like this..
My XAML COde
<telerik:RadRichTextBox Name="editor" Grid.Row="1" IsReadOnly="True">
<telerik:RadRichTextBox.Resources>
<telerikHtml:HtmlDataProvider x:Name="htmlDataProvider" RichTextBox="{Binding ElementName=editor}" Html="{Binding OrignalData}"/>
</telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>
My ViewModel Code
private string _orignalData;
public string OrignalData
{
get { return _orignalData; }
set { _orignalData = value; }
}
public ViewModel()
{
string resource = "test.html";
Uri uri = GetResourceUri(resource);
using (Stream stream = Application.GetResourceStream(uri).Stream)
{
StreamReader reader = new StreamReader(stream);
this.OrignalData = reader.ReadToEnd();
}
}
private static Uri GetResourceUri(string resource)
{
AssemblyName assemblyName = new AssemblyName(typeof(MainPage).Assembly.FullName);
string resourcePath = "/" + assemblyName.Name + ";component/" + resource;
Uri resourceUri = new Uri(resourcePath, UriKind.Relative);
return resourceUri;
}
now which provider i have to use in xaml to open docx file, is it possible to write only a common provider which can open all the fles for me.
regards
rahul
I want to open docx, txt, html file in my project,
for html file and txt file i have done like this..
My XAML COde
<telerik:RadRichTextBox Name="editor" Grid.Row="1" IsReadOnly="True">
<telerik:RadRichTextBox.Resources>
<telerikHtml:HtmlDataProvider x:Name="htmlDataProvider" RichTextBox="{Binding ElementName=editor}" Html="{Binding OrignalData}"/>
</telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>
My ViewModel Code
private string _orignalData;
public string OrignalData
{
get { return _orignalData; }
set { _orignalData = value; }
}
public ViewModel()
{
string resource = "test.html";
Uri uri = GetResourceUri(resource);
using (Stream stream = Application.GetResourceStream(uri).Stream)
{
StreamReader reader = new StreamReader(stream);
this.OrignalData = reader.ReadToEnd();
}
}
private static Uri GetResourceUri(string resource)
{
AssemblyName assemblyName = new AssemblyName(typeof(MainPage).Assembly.FullName);
string resourcePath = "/" + assemblyName.Name + ";component/" + resource;
Uri resourceUri = new Uri(resourcePath, UriKind.Relative);
return resourceUri;
}
now which provider i have to use in xaml to open docx file, is it possible to write only a common provider which can open all the fles for me.
regards
rahul