xaml - Setting Grid RowDefinitions/ColumnDefinitions properties in a style -


suppose have 2 or more grids share same structure (rows/columns count , properties equal).

is possible create style , set rowdefinitions/columndefinitions?

i have tried that. exception when application tries parse xaml:

xamarin.forms.xaml.xamlparseexception: position 14:9. property value null or not ienumerable

my source code:

<stacklayout>     <stacklayout.resources>         <resourcedictionary>             <style targettype="grid">                 <setter property="rowdefinitions">                     <setter.value>                         <rowdefinition />                         <rowdefinition />                     </setter.value>                 </setter>             </style>         </resourcedictionary>     </stacklayout.resources>      <grid>         <label grid.row="0" text="(grid #1) row #1" />         <label grid.row="1" text="(grid #1) row #2" />     </grid>      <grid>         <label grid.row="0" text="(grid #2) row #1" />         <label grid.row="1" text="(grid #2) row #2" />     </grid>      <grid>         <label grid.row="0" text="(grid #3) row #1" />         <label grid.row="1" text="(grid #3) row #2" />     </grid> </stacklayout> 

position 14:9 in exception refers first <rowdefinition /> tag.

you can't define rowdefinition , columndefinition within style, can create them reusable resources. think you're looking for. defining columndefinitioncollection , rowdefinitioncollection allows reuse them many grids create consistent look.

<resourcedictionary>     <columndefinitioncollection         x:key="mycolumndefinitioncollection">         <columndefinition             width="50" />         <columndefinition             width="100" />         <columndefinition             width="150" />     </columndefinitioncollection>     <rowdefinitioncollection         x:key="myrowdefinitioncollection">         <rowdefinition             height="50" />         <rowdefinition             height="50" />         <rowdefinition             height="100" />         <rowdefinition             height="100" />     </rowdefinitioncollection> </resourcedictionary> 
<grid      columndefinitions="{staticresource mycolumndefinitioncollection}"     rowdefinitions="{staticresource myrowdefinitioncollection}"> </grid> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -