xamlformatprovider exclude property

8 posts, 0 answers
  1. Sergey
    Sergey avatar
    22 posts
    Member since:
    Aug 2008

    Posted 29 Nov 2011 Link to this post

    I am using InlineUIContainer with a custom control.  It serializes some properties of that control into XAML.  Is there a way to have control over what is serialized via an attribute?
    Thanks.
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 01 Dec 2011 Link to this post

    Hi Sergey,

    There are no customization options for the way XamlFormatProvider serializes the document.
    Could you provide some more details on the customization options you would find convenient in this scenario?
    Looking forward to your reply.

    All the best,
    Iva Toteva
    the Telerik team

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

  3. DevCraft banner
  4. Sergey
    Sergey avatar
    22 posts
    Member since:
    Aug 2008

    Posted 01 Dec 2011 Link to this post

    here is my scneario.  I am using InlineUIContainer with a custom custom control in it, bound to a view model.  By default all properties of a view model will be seriualized, where I want to control which ones are serialized into XAML.

    Thank you.
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 06 Dec 2011 Link to this post

    Hi Sergey,

    We will add ExportSettings for XamlFormatProvider, the way it has been done for HtmlFormatProvider, RtfFormatProvider and PdfFormatProvider. More information on the way export settings are used can be found here. We will probably implement the same mechanism which has been implemented for HtmlFormatProvider - introducing an InlineUIContainerExporting event. In this way, it will be possible to handle the event and provide your implementation in place of the default one. 
    When the feature is implemented, we will make sure to update the article to include XamlFormatProvider.

    Please, let us know if you find this solution appropriate. 

    Kind regards,
    Iva Toteva
    the Telerik team

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

  6. Dustin
    Dustin avatar
    79 posts
    Member since:
    Oct 2012

    Posted 27 Feb 2012 Link to this post

    Currently with the HtmlExportSettings you can exclude FloatingImageBlocks from the exports, but with the PdfExportingSettings you can only exclude the InlineUIContainers. Is there any way to exclude FloatingImageBlocks from PDF exports or is this feature going to be incorporated at some point?
  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 01 Mar 2012 Link to this post

    Hi Dustin,

    There is no customization point that prevents the export of FloatingImageBlocks to PDF.

    With HtmlFormatProvider, we have provided such settings because it is useful in the cases when you want to export and import images separately and reference them in the HTML using a URI such as a relative path to the image. As HTML is a text-based format, one could implement this functionality in a quite straightforward way.
    When it comes to the PdfExportSettings, as you have noticed in the ticket you opened, the InlineUIContainersExportMode setting is not applied, i.e. InlineUIContainers are always exported as images. We will fix this behavior, but providing a customization option for images is not considered at this point. You can, however, remove the images from the document before export. Please, refer to the sample application attached in the ticket, which performs the same operation for InlineUIContainers.

    Greetings,
    Iva Toteva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  8. Dustin
    Dustin avatar
    79 posts
    Member since:
    Oct 2012

    Posted 01 Mar 2012 Link to this post

    But if I remove the Images from the document before exporting then they are removed from the original document and if I make a copy of the document (via export to xaml and then import into a new document that just makes the export process longer which is not an option). If there a way to remove the images without affecting the original or reversing/unding those removals after exporting?
  9. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 06 Mar 2012 Link to this post

    Hi Dustin,

    There are two ways to accomplish the export of the document without the images.

    The first one is to create a copy of the document, iterate through it deleting the images and export the result. Using this approach, you can remove the images from the paragraph using the document collection like this:

    image.Parent.Children.Remove(image);

    The second option is not to create a copy of the document and delete the images in the editor. The time for copying the document will be spared, but you will have to delete the images using the Delete method of RadRichTextBox in order to preserve the history. This can be done like this:
    IEnumerable<FloatingImageBlock> floatingImageBlocks = this.AssociatedRichTextBox.Document.EnumerateChildrenOfType<FloatingImageBlock>();
    foreach (var imageBlock in floatingImageBlocks)
    {
        DocumentPosition start = new DocumentPosition(this.AssociatedRichTextBox.Document);
        DocumentPosition end = new DocumentPosition(this.AssociatedRichTextBox.Document);
     
        InlineLayoutBox inlineLayoutBox = imageBlock.FirstLayoutBox as InlineLayoutBox;
        InlineLayoutBox nextLayoutBox = inlineLayoutBox.AssociatedInline.NextSibling.FirstLayoutBox as InlineLayoutBox;
     
        start.MoveToInline(inlineLayoutBox, 0);
        end.MoveToInline(nextLayoutBox, 0);
     
        this.AssociatedRichTextBox.Document.Selection.SetSelectionStart(start);
        this.AssociatedRichTextBox.Document.Selection.AddSelectionEnd(end);
        this.AssociatedRichTextBox.Delete(false);
        deletedImages++;
    }

    You can execute this code in a save command you have created and wired the UI to work with. After the export is complete, you can undo the changes:

    for (int i = 0; i < deletedImages; i++)
    {
        this.AssociatedRichTextBox.Undo();
    }

    This method for deleting the images is slower because RadRichTextBox creates contexts for the execution of the commands in order to be able to undo and redo the changes to the document. Furthermore, the 

    You can choose which method will be more appropriate in your application depending on the size of the documents and the number of floating images that will normally be present in the document. All the best,
    Iva Toteva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
DevCraft banner