Hi, I have my RichTextBox project setup to edit existing and new docx documents. It behaves the same as the SDK example, "Telerik Editor".
But I'm not sure even the SDK sample behaves correctly. If you have an existing document pulled up in the editor and you press Save, it should just save the document and not show you any dialog. But Telerik takes you to the Save As dialog and doesn't even set the 'File name' to the document you have open. Also, with Save As, it should default 'File name:' to the name of the current document you are editing. Lastly, is there a way to add logic for X-ing out of the editing window so that it will go to the Save As dialog if anything has changed? And then 'File name:' would also need to default to the current document name.
Thanks
John
But I'm not sure even the SDK sample behaves correctly. If you have an existing document pulled up in the editor and you press Save, it should just save the document and not show you any dialog. But Telerik takes you to the Save As dialog and doesn't even set the 'File name' to the document you have open. Also, with Save As, it should default 'File name:' to the name of the current document you are editing. Lastly, is there a way to add logic for X-ing out of the editing window so that it will go to the Save As dialog if anything has changed? And then 'File name:' would also need to default to the current document name.
Thanks
John
5 Answers, 1 is accepted
0
Hello John,
RadRichtTextBox exposes a single SaveCommand that invokes SaveFileDialog and allows you to save to specified location. We are planning on creating an example for RadRichTextBox for WPF that will demonstrate both Save and Save As option by preserving the path to the document on the file system. In fact, this could be easily achieved with the public API of the control.
However, please note that such example cannot be implemented for the Silverlight version of the control. The reason for this is the fact that the Silverlight framework imposes limitations that prevent from accessing the file system on the client. Similar limitations prevent from specifying the file name and/or directory when showing the SaveFileDialog as well. I am afraid there is not much we can do about this.
Regards,
Petya
Telerik
RadRichtTextBox exposes a single SaveCommand that invokes SaveFileDialog and allows you to save to specified location. We are planning on creating an example for RadRichTextBox for WPF that will demonstrate both Save and Save As option by preserving the path to the document on the file system. In fact, this could be easily achieved with the public API of the control.
However, please note that such example cannot be implemented for the Silverlight version of the control. The reason for this is the fact that the Silverlight framework imposes limitations that prevent from accessing the file system on the client. Similar limitations prevent from specifying the file name and/or directory when showing the SaveFileDialog as well. I am afraid there is not much we can do about this.
Regards,
Petya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
John
Top achievements
Rank 1
answered on 03 Mar 2015, 08:12 PM
Hi Petya, I'm trying to implement some code from the Windows.Closed event to ask the user if they would like to Save any changes made to the document. Do you have any SDK's or blogs that discuss this? I'd like to see if you associate the handler in the View constructor and how. Also, what mechanism you use to check the document to see if it needs to be saved again. Maybe an instance is saved after every Save action and used at Windows.closed.
Thanks,
John
Thanks,
John
0
Hi John,
We just added a similar example to our SDK repository on GitHub. You could also use the Telerik SDK Samples Browser to navigate the examples.
Please note that the example is only available for WPF. This is due to the fact that the Silverlight framework imposes limitations on access to files on the client machine for security reasons. Implementing this functionality in a Silverlight project is not possible.
Regards,
Petya
Telerik
We just added a similar example to our SDK repository on GitHub. You could also use the Telerik SDK Samples Browser to navigate the examples.
Please note that the example is only available for WPF. This is due to the fact that the Silverlight framework imposes limitations on access to files on the client machine for security reasons. Implementing this functionality in a Silverlight project is not possible.
Regards,
Petya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
John
Top achievements
Rank 1
answered on 16 Mar 2015, 03:52 PM
Hi Petya, these examples are very useful. Thank you. But if you open a doc and modify it and then X out of the window, it closes down without asking the user if they would like to save the file. I see how I can use the "DocumentContentChanged" event to tract when the doc is modifiied but I don't quite see how to tie this into the Windows.Closed event. Could you shed some light on this?
John
John
0
Hello John,
In the context of the sample project in SDK repository you could use the Closing event. You could even cancel the event if you'd like to, for example:
Note that you may need to modify the logic to better suit your needs. In the example the isDirty property is set to false when the document in the editor is changed, whereas you'd need to set it when the current document is saved as well.
Regards,
Petya
Telerik
In the context of the sample project in SDK repository you could use the Closing event. You could even cancel the event if you'd like to, for example:
private
void
Window_Closing(
object
sender, System.ComponentModel.CancelEventArgs e)
{
if
(
this
.isDirty)
{
MessageBox.Show(
"Please save your work first."
);
e.Cancel =
true
;
}
}
Note that you may need to modify the logic to better suit your needs. In the example the isDirty property is set to false when the document in the editor is changed, whereas you'd need to set it when the current document is saved as well.
Regards,
Petya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.