This is a migrated thread and some comments may be shown as answers.

Setting HorizontalContentAlignment

6 Answers 103 Views
Window
This is a migrated thread and some comments may be shown as answers.
Darren Stoppler
Top achievements
Rank 1
Darren Stoppler asked on 26 Apr 2010, 04:33 PM
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

6 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 27 Apr 2010, 01:10 PM
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.
0
Darren Stoppler
Top achievements
Rank 1
answered on 27 Apr 2010, 01:51 PM
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
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 29 Apr 2010, 12:47 PM
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.
0
Darren Stoppler
Top achievements
Rank 1
answered on 29 Apr 2010, 03:34 PM
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
0
Darren Stoppler
Top achievements
Rank 1
answered on 29 Apr 2010, 03:39 PM
Here's the XAML.

Thanks
0
Darren Stoppler
Top achievements
Rank 1
answered on 29 Apr 2010, 04:20 PM
It's ok now thanks.  It seemed to be a margin on the grid.
Tags
Window
Asked by
Darren Stoppler
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Darren Stoppler
Top achievements
Rank 1
Share this question
or