How to create a custom control that can be larger than its generated size using WPF
I have created a custom control using WPF and I want to add it to the window. I did this, but I cannot control my level higher than the height than its own xaml file. My MaxWidth and MaxHeight are infinite, but I can't seem to make the control taller than the one in its xaml file.
To get around this, I have to make all my user control huge, so I can sort it as I wish. It doesn't seem right, I must be missing something.
source to share
Removing height and width is the way to go. The designer (blend) has special designer width and height properties that they can use for design, but will not set the height for runtime.
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="412" d:DesignHeight="230"
This is the xaml that will be at the top of the / UserControl window. This should help explain things.
source to share
Ok, after some further investigation, I was wrong. its a lattice which is causing the problem. If I set the Grid Width and Heigth to Auto then everything works fine, but I lose the ability to use the constructor.
I have all the alignments set to Stretch for both the Grid and its controls.
So, everything works fine if I set Grid.Width = Auto and Grid.Height = Auto, but when I do, I lose the ability to use the constructor.
source to share