How to use x: object and when?

When you pass arguments markup extension x:Argumentsfor custom designers, as indicated by the docs , I can see the use of specific types of data, such as x:Int32or x:String, but a use case x:Object? And what else, to use it, what needs to be put between a tag?<x:Object> ??? </x:Object>

In the case of integers or strings, it is natural to consider them as a variable assignment, and the variables are then passed to the constructors. But in the case, Objectsuch a variable is usually created by another user-defined class, so how do you specify which class you want to create?

+4
source share
3 answers

x:Object . x:Object System.Object, . ,

 public class MyClass {
     public MyClass(object arg) {

     }
 }

:

<my:MyClass>
  <x:Arguments>
    <x:Object />
  </x:Arguments>
</my:MyClass>

,

new MyClass(new object());

Object - , - . , - x:Object, :

<my:MyClass>
  <x:Arguments>
    <x:String>string</x:String>
  </x:Arguments>
</my:MyClass>

new MyClass("string");
+2

:

x: . , , XAML. .

Xamarin , , x: Key .

, x: Key, ResourceDictionary.

, :

<local:MockFactory >
     <x:Arguments>
         <x:Array Type="{x:Type x:Object}">
             <x:String>Foo</x:String>
             <x:String>Bar</x:String>
         </x:Array>
     </x:Arguments>
</local:MockFactory>

+2

, x: - .

Suppose you have a screen that displays and tells the user that if the data being imported is not supported, they will see the result as follows: and then you will see the data template for x: Object. An easy way to do this would be as follows:

<ContentControl>
  <ContentControl.Content>
    <x:Object/>
  </ContentControl.Content>
</ContentControl>

so the most specific data template available is x: Object one, and this is what is shown.

the Object class does not contain meaningful data, so there really is no reason to write

<x:Object></x:Object> 

because there is no content for the type.

+1
source

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


All Articles