Programming
C# – Programmatically set Width/Height attribute to “Auto”
by admin on Feb.22, 2013, under Programming
I’ve noticed the .Width or .Height attribute expects a Double value in WPF. In contrast to XAML it’s therefor impossible to set one of these attributes to “Auto”. Luckily there’s another way of setting it to Auto from C-Sharp code:
ListView1.Width = Double.NaN;
Double.NaN (or double.NaN) pretty much has the same effect as the Auto attribute in XAML.