Resize HTMLPlaceHolder as per the text it containing

11 posts, 0 answers
  1. Anuraj Temkar
    Anuraj Temkar avatar
    2 posts
    Member since:
    Mar 2010

    Posted 05 Mar 2010 Link to this post

    Hi, can anyone tell me how do i resize the HTMLPlaceHolder Control so that when i put some Text in it, it will not show any scroll to the HTMLPlaceHolder Control?? i mean i don’t want scrolls to the HTML Place holder control. Instead I want to resize it according to the text in it. i used (ObjHTMLPlaceHolder.HtmlPresenter.Children[0] as HtmlElement).SetAttribute("scrolling", "no"); but did not work.
    is there any way to get the height of HTMLPlaceHolder-Control's HtmlPresenter in Pixcel so that i can use it to set Height of the HTMLPlaceHolder Control

  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 09 Mar 2010 Link to this post

    Hi Anuraj Temkar,

    It is supposed to work this way out of the box if you don't set the Width or Height attributes, unfortunately there is a problem with this that is logged here:
    http://www.telerik.com/support/pits.aspx#/public/silverlight/269

    Regards,
    Valentin.Stoychev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 07 Sep 2010 Link to this post

    Has this been fixed yet, or is it still an Issue.  I have the same problem.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Sep 2010 Link to this post

    Hi Travis,

    The issue isn't fixed yet. However, you can vote for it thus increasing its priority.

    I hope this isn't a showstopper for you. Please accept our apology for the caused inconvenience.

    Sincerely yours,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 13 Sep 2010 Link to this post

    Unfortunately, it is a showstopper for me.  The html displayed needs to flex width and height attributes.  I've pretty much given up on the rad controls for editing and displaying HTML in silverlight apps.  I've instead decided to use a free control available here:
    http://www.vectorlight.net/controls/rich_textbox.aspx

    This editor is not as good in my opinion as what I've seen with most rad editors, but it does provide very basic HTML editing and does flex width and height correctly when displaying HTML.  It was also a bit easier for me to create a wrapper for this control.
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Sep 2010 Link to this post

    Hello Travis,

    I am sorry to hear that. Still, you say that you need a control to edit and display html content, so I was wondering if you have tried our RadRichTextBox. Here you can find more info about it.

    With Telerik RadRichTextBox control you can load rich-text (XAML, HTML) or plain text (TXT) into the control, you can format and edit it and then export it back to plain text, XAML, Docx or Html formats. Read more

    Please give the RadRichTextBox a try and let us know if it works for you. We will highly appreciate any feedback on it as well.

    Kind regards,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 16 Sep 2010 Link to this post

    Yes, I tried RadRichTextBox.  I eventually got it to work as far as editing goes.  It seemed like you have to do all this extra work  and add extra code to your xaml file to make it work for editing HTML.  The other problem was that the HTML that it created caused problems for the control I was using to display the HTML.  The display control was not a rad control.  The rad control for dispalying HTML doesn't work as stated previously in thist post.  I can't remember the exact details of the problem.  I think the display control wouldn't flex properly or something when it displayed the HTML that the RadRichTextBox created. 

    I think Telerik needs to create an HTML editor for silverlight that actually works and doesn't involve so much tweaking.  Displaying everything in XAML just isn't an option.  I have too many apps that are not silverlight based that need to display content in HTML format. 
  9. Mike
    Admin
    Mike avatar
    640 posts

    Posted 22 Sep 2010 Link to this post

    Hi Travis,

    Since RadHmlPlaceHolder controls wraps browser specific features it would not allow measuring of its content thus I am afraid precise automatic resizing is not possible. RadRichTextBox on the other hand has its own text rendering engine and supports automatic Height calculation based on its content. In the current version it has problems with automatic With calculation which we will address in the next release. We will be glad to know if you experience any other issues related to this new control.

    Regarding you new control request, can you please elaborate a bit more on your scenario concerning HTML editing in Silverlight application?

    Greetings,
    Mike
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 22 Sep 2010 Link to this post

    Here's what I mean by tweaking: to get the richtextbox control to work for HTML you have to add this reference:

    xmlns:documents="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents"
    xmlns:documentsHtml="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html"

    and then this:

    <UserControl.Resources>
            <documentsHtml:HtmlDataProvider SetupDocument="HtmlDataProvider_SetupDocument" x:Key="htmlDataProvider" RichTextBox="{Binding ElementName=SystemDescRTB}" Html="{Binding ElementName=TBSystemDesc, Path=Text, Mode=TwoWay}" />
        </UserControl.Resources>

    Additionally, you need to insert the RadRichTextBoxRibbonUI (I won't list the xaml this creates since it is so insanely long), a TextBox control which is what you actually bind to and then some more code in your code behind file so that your margins aren't screwed up:

     

     

     

    private void HtmlDataProvider_SetupDocument(object sender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e)
           {
               e.Document.SectionDefaultPageMargin =
               new Telerik.Windows.Documents.Layout.Padding(10, 10, 10, 10); //set margins for HTML format, otherwise margins are skewed
               if (e.Document.Sections.First.Paragraphs.First != null)
               {
                   e.Document.Sections.First.Paragraphs.First.FontSize = 13.33; //set font size to 10pt
               }
           }

     

     

    I tried to create a wrapper that did all of this, but was having some issues making that work.  What I'm saying is that all of this should not be necessary.  All I should have to do is set some property in the radrichtextbox which says I want to edit in HTML mode. 


  11. Mike
    Admin
    Mike avatar
    640 posts

    Posted 27 Sep 2010 Link to this post

    Hi Travis,

    The architecture of RadRichTextBox control and the related document format providers is designed to allow working with various input/output formats and different editing user experience (RbbonUI toolbars etc). It is also important to know that RadRichTextBox is not designed to be an HTML editor. Its internal document model resembles much more MS Word than HTML document.

    In your case the best approach would be to create an user control that encapsulates all the logic if you wish to reuse it across the application. I prepared a project for you that demonstrates a possible approach to this.

    Let me know if this helps.

    Kind regards,
    Mike
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 27 Sep 2010 Link to this post

    Thanks for the example.  I'll try it out.
Back to Top
DevCraft banner