Search code examples
c#.netsilverlightuser-interfacesilverlight-5.0

How to create Semi transparent Grid using c# code


I am a c# silverlight developer and i am under a situation where i have created GUI using c# only(no use of xaml) . How i created this GUI :

I have coded for it in c# and there is 1 grid(with 3 number of rows) and inside that grid i have 3 more grids in each row of previous grid one corresponding to "Automatic Skewing" another grid in second row corresponds to "Auto Model" and the third one corresponds to "Skew".

What i have to do ?: Please note that the grid in third row contains a semi-transparent GUI. I want to do my gui semi transparent like this because i want to display the GUI of the third row but i don't want to the user to click(edit) on third row , he must be able to see it with semi transparency (but can not click on it as you can see the third row (corresponding to skew) in snapshot below it is semi transparent and user cannot click on it).

How to achieve this using c# code only(not xaml). Any Idea ?

As you can see the Skew grid (3rd row) is semi transparent.


Solution

  • Based on your specification I think it would be the best to put all content of the third row into some container, set the IsEnabled property of it to false(as SilverLight's Grid seems to lack this property, you can try to wrap it in a ContentControl), and also set an Opacity lower than 1 to it.

    Both the IsEnabled and the Opacity property affects the child elements.

    Maybe it would be better to actually bind those values, as I suspect that the enabled/disabled state of the third row depends on some condition. (Both values - IsEnabled and Opacity - can be bound to the same condition, in case of the opacity you might want to use a converter)

    By the way: I feel it would be much easier with XAML...