VIJI VIJI - 1 year ago 155
C# Question

MeasureOverride available size is infinity

I have implemented a simple custom control in

platform. My problem is when I placed this control inside the
I got this error.

System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has
been returned from a call to a COM component. at
Windows.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)

width returns
, can anyone advise me how to resolve this problem?

<myControl:MySimpleControl />

Answer Source

When the custom control was added the children of StackPanel, throw the same exception. Because StackPanel width is infinity when Orientation is Horizontal. HubSection has also the same scenario like this.

So in this case have to allocated default(specific) Width for the control then call the InvalidateMeasure() to resolve this problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download