views:

35

answers:

1

Grid related UI design question

I want some 16-grid (4 rows and 4 columns) user interface, and fill the grid with some round shapes. I also want to use the MouseOver, mouse left button down, and Mouse Left Button Up events to set the state of grids as selected or not selected.

My questions: 1. How fill the grid with some round shapes? by SetColumn and SetRow? 2. How to make the grids respond to the mouse please?

Thanks

   <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
+3  A: 

I'd suggest you initialize the grid in code instead of XAML. Since you need pretty repetitive stuff (4×4 shapes, each one hooked up to the same event handlers) you definitely don't want to do that in XAML.

You can use Grid.SetRow and Grid.SetColumn to position the controls you create.

You can then use the MouseEnter and MouseLeave events for hover effects (or even create triggers based on that).

Joey