WPF is not designed so primitively (and, ultimately, not so unreliably and inconveniently) to allow you to just set the size of control. All rendered sizes are defined by the general layout of the window.
First of all, everything comes from or to the size of the windows, separately by horizontal and vertical dimension. It's either the sizes of all UI elements inside a window are defined by the total size of the window, explicitly chosen, or the size of the window is defined by the size of content. This is defined by the
SizeToContent
property:
https://msdn.microsoft.com/en-us/library/system.windows.window.sizetocontent(v=vs.110).aspx[
^].
And then, the size of each and every control is defined by its content and properties, such as
Control.Padding
and
FrameworkElement.Margin
, as well as related factors, such as
Grid.ColumnDefinitions
and
, and other controls' properties. Please see:
https://msdn.microsoft.com/en-us/library/system.windows.controls.control.padding%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.margin%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.windows.controls.grid.columndefinitions(v=vs.110).aspx[
^],
https://msdn.microsoft.com/en-us/library/system.windows.controls.grid.rowdefinitions(v=vs.110).aspx[
^].
I referenced these properties just for illustration, not pretending for complete explanation. You can get this understanding if you study WPF
layout model:
https://msdn.microsoft.com/en-us/library/ms745058%28v=vs.110%29.aspx[
^].
So, what to do? Rethink your design. You don't need to try to arbitrary change the size of some separate control. Probably WPF layout model is more rational that you thought. It's better to embrace in instead of fighting it.
—SA