Setting HorizontalContentAlignment

7 posts, 1 answers
  1. Darren Stoppler
    Darren Stoppler avatar
    36 posts
    Member since:
    Apr 2010

    Posted 26 Apr 2010 Link to this post

    I am new to .net and can't work out why on the www.HorizontalContentAlignment = "Stretch" line of the code at the end of this message, I get the following error:-

    Error   1   Cannot implicitly convert type 'string' to 'System.Windows.HorizontalAlignment'

    This works fine in the XAML examples.

    The code:

    RadWindow win = new RadWindow();
                WindowInCode.Control pnl = new WindowInCode.Control();
                win.Content = pnl;
                win.HorizontalContentAlignment = "Stretch";

    Thanks
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 27 Apr 2010 Link to this post

    Hi Darren,

     The XAML parser is using TypeConverters in order to convert the strings to actual objects. In this case it converts string to the enumeration called HorizontalAlignment. If you need to set this in C# you should do the following:

    win.HorizontalContentAlignment = HorizontalAlignment.Stretch;

    Best wishes,
    Miroslav Nedyalkov
    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. Darren Stoppler
    Darren Stoppler avatar
    36 posts
    Member since:
    Apr 2010

    Posted 27 Apr 2010 Link to this post

    Hi Miroslav,

    Thanks for your reply, that's ok now.

    Do you have any example code that shows a Window containing a user control?  I have created a project that does this but when I resize the RadWindow, the grid within the user control doesn't resize, it just stays roughly in the center of the window (please see attached graphic).  I would like the content to always fill the RadWindow.  I have locked the outlook bar control in the grid but I would like the data grid on the right to resize with the window.

    Are there any tips that you could give me on this?

    Thanks once again.

    Darren
  5. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 29 Apr 2010 Link to this post

    Hello Darren,

     Most probably you didn't removed the Width and Height attributes at the root tag of the UserControl - the default template contains them and is causing this problem.

    You could refer to the following example that accomplishes this task: http://demos.telerik.com/silverlight/#Window/UserControlExample.

    Best wishes,
    Miroslav Nedyalkov
    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. Darren Stoppler
    Darren Stoppler avatar
    36 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2010 Link to this post

    Hi Miroslav,

    Thank you, that solved that problem and I am very close to getting the result that I wanted :)

    One issue that I have is that the Outlook control is going outside of the RadWindow.  It sizes and behaves correctly although it's outside of the window.  I have attached a screen print.

    Thanks once again.

    Darren
  7. Darren Stoppler
    Darren Stoppler avatar
    36 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2010 Link to this post

    Here's the XAML.

    Thanks
  8. Darren Stoppler
    Darren Stoppler avatar
    36 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2010 Link to this post

    It's ok now thanks.  It seemed to be a margin on the grid.
Back to Top
DevCraft banner