Size of UserControl in ContentControl after ActivateItem method

Topics: Framework Services, UI Architecture
Aug 9, 2011 at 4:40 PM
Edited Aug 9, 2011 at 4:42 PM

I have a ContentControl on my ShellView named "ActiveItem".  I am using the "ActivateItem" method to instantiate one of a set of UserControls at runtime.  It all works as expected except that the UserControl Height and Width are being set to a size much smaller than the space that is available.  It appears that the UserControl is being set to a size that is a function of the controls that are contained in the UserControl.  When I place a different control (ex: Canvas) in that same space it very happily sizes itself to fill the space.  I have tried with and without the Alignment="Stretch" properties.

Thanks, Jim


Aug 9, 2011 at 5:01 PM

Does it work better if you set the HorizontalContentAlignment and the VerticalContentAlignment properties to stretch?

Aug 9, 2011 at 7:15 PM
Edited Aug 9, 2011 at 7:16 PM

Success!  That was it.  I added HorizontalContentAlignment="Stretch" and the VerticalContentAlignment="Stretch" to the ContentControl and that took care of the problem.  You rock!  Thank you

I have much to learn in the XAML world