c# - WPF layout created dynamically using MVVM -
c# - WPF layout created dynamically using MVVM -
i'm trying postion views window in layout rectangle base of operations while using mvvm pattern.
in winforms able utilize width, height, x , y of rectagle position controls setting same properties on control.
now i'm rewriting code wpf using mvvm , i'm lost.
this i'm trying do:
this thought might work not.
<grid showgridlines="true"> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> <rowdefinition /> <rowdefinition /> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition /> <columndefinition /> <columndefinition /> <columndefinition /> <columndefinition /> </grid.columndefinitions> <itemscontrol itemssource="{binding virtualscreens}" grid.issharedsizescope="true" > <itemscontrol.itemtemplate> <datatemplate> <button grid.row="{binding row}" grid.column="{binding column}" content="{binding name}"></button> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </grid> public class virtualscreen : observableobject { string name; int row; int column; public string name { { homecoming name; } set { name = value; raisepropertychanged(() => name); } } public int row { { homecoming row; } set { row = value; raisepropertychanged(() => row); } } public int column { { homecoming column; } set { this.column = value; raisepropertychanged(() => column); } } }
thank type of help
you can utilize wpf grid layout elements shown in ui. three-row, three-column grid work fine you:
<grid> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition /> <columndefinition /> <columndefinition /> </grid.columndefinitions> <button grid.row="1" grid.column="1" grid.columnspan="2" grid.rowspan="2">this big top left section</button> <button grid.row="1" grid.column="2">top right</button> <button grid.row="2" grid.column="2">middle right</button> <button grid.row="3" grid.column="1">bottom left</button> <button grid.row="3" grid.column="2">bottom center</button> <button grid.row="3" grid.column="2">bottom right</button> </grid>
checkout grid row , column spanning more info.
c# wpf layout mvvm rectangles
Comments
Post a Comment