views:

46

answers:

1

I have a feature matrix implemented with Silverlight's Grid where users need to select a product. How can I indicate selection with a rectangle around the whole selected column?

It is easy to put a CheckBox at the bottom of each product's column, but that is too dull. I would have preffered to use SL Toolkit's DataGrid (with built-in row selection), but it cannot be orientated vertically for a feature matrix...

Thanks, Carl

+1  A: 

In order to place a rectangle round the contents of a whole column in a Silverlight Grid you simply place the Rectangle as the last child item in the Grid and assign the property Grid.RowSpan on it to the number of rows in the grid and Grid.Column to the column you wish to highlight. E.g.:-

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <!-- Row Definitions (say 4 in this case)-->
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <!-- Column definitions -->
    </Grid.ColumnDefinitions>

    <!-- Grid contents -->

    <Rectangle Grid.RowSpan="4" Grid.Column="1" Stroke="Blue" StrokeThickness="1" />

</Grid>

Having said that it would seem to be hard work to manage a Grid to display something data driven like a product matrix. You state that a DataGrid would work for you if it could render "rows" horizontally. Well a ListBox can be styled that way so that is what I'd been inclined to use.

AnthonyWJones
How would you style a ListBox to do this? Matrix cells can contain several lines of text and I could not find a way to align cell heights without the Grid.
carlmon
@carlmon: Ah ok I see your problem, with difficulty ;) The correct level to create such a control would be to derive from `Selector` and create your own custom panel and panel item controls to be displayed. Whilst this would be a more complete solution its probably a lot harder than what you are already doing.
AnthonyWJones