Nullable type in x: TypeArguments

Is it possible to pass a NULL type to arguments of a general XAML type (x: TypeArguments)?

I have:

 <base:ControlBase
  x:TypeArguments="sys:Int32"
  ...

I need Int32 to be null. sort of

<base:ControlBase
  x:TypeArguments="sys:Nullable<sys:Int32>"
 ...

Which seems to be invalid XML / XAML.

I tried to declare it as an sys:Nullabe&lt;sys:Int32&gt;error:

'sys.Nullable' is not a valid type name name for a generic argument

+4
source share
1 answer

No, this is impossible, unfortunately. You need to create an intermediate class to solve this problem (I tried all possible methods, it just doesn't work).

<base:NullableInt32ControlBase ... >

Where NullableControlBaseis the intermediate class:

public class NullableInt32ControlBase : ControlBase<int?>
{ }
+3
source

Source: https://habr.com/ru/post/1621400/


All Articles