c# - I need a responsive grid (cell can be clicked) on the form, what control should be used? -


i need show grid on form, displays 32 32 cells, each cell can clicked operation(like windows calendar app). i'v considered buttons , panels, that'll 1024 controls. better way?

here's way create responsive grid buttons in wpf:

the responsiveness created gridlength(1, gridunittype.star)

mainwindow.xaml.cs

public partial class mainwindow : window {     public mainwindow()     {         initializecomponent();         (int x = 0; x < 32; x++)         {             buttongrid.columndefinitions.add(new columndefinition             {                 width = new gridlength(1, gridunittype.star)             });             buttongrid.rowdefinitions.add(new rowdefinition             {                 height = new gridlength(1, gridunittype.star)             });              (int y = 0; y < 32; y++)             {                 var bt = new button();                 bt.content = x + "" + y;                 grid.setrow(bt, x);                 grid.setcolumn(bt, y);                 buttongrid.children.add(bt);                 bt.click += bt_click;             }         }     }      private void bt_click(object sender, routedeventargs e)     {         button bt = (button)sender;         bt.background = brushes.black;     } } 

mainwindow.xaml

<grid name="buttongrid"></grid> 

be aware resizing going quite slow.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -