Re: DataGridCheckBoxColumn (fixed?!)

2011-12-06 Thread Jordan Knight
Create a user control and place it in the cell. 


Have a dependency property on it to publish the select color back to where you 
need...

Cheers,

Jordan. 

On 06/12/2011, at 7:07 PM, Greg Keogh g...@mira.net wrote:

 Now that’s solved, I have an even more ambitious thing to try.
  
 I want to turn a DataGrid cell into a colour picker. I have a template column 
 containing a Grid with a TextBlock inside. The grid background is bound to 
 the colour (via a converter) and I can see a cell value like # with a 
 red background. I now have to:
  
 1. Display the ARGB value as a known colour (if it corresponds to one).
 2. Make the mouse turn to a hand when over the colour cells.
 3. Open some sort of colour picker when the colour cells are clicked and get 
 that value back to the cell and bound property (luckily we’re using the C1 
 kit and I think they have a colour picker).
  
 Fun eh?! I estimate 6 hours work. In WinForms it would take 15 minutes, but I 
 shouldn’t get sentimental.
  
 Greg
 ___
 ozsilverlight mailing list
 ozsilverlight@ozsilverlight.com
 http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
___
ozsilverlight mailing list
ozsilverlight@ozsilverlight.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight


RE: DataGridCheckBoxColumn (fixed?!)

2011-12-06 Thread Greg Keogh
It’s all working now.  It turns out I didn’t need to walk up anywhere for the 
DataContext, as the I managed to embed a C1 colour picker control into the 
template cell and bind it directly to the Colour property. The screen shot I’ve 
pasted below (if your email can see it) shows how I’ve bound a grid to a data 
source with bool and Colour properties and it all works with little code. I did 
have to use template cells as the CheckBoxColumn has stupid behaviour I 
previous whinged about. The Colour cell is a Grid with a TextBlock and the 
picker. I used a converter to show the grid background colour and friendly 
text. I had many subtle problems with column sizing, binding choices and the 
poor C1 documentation about their picker, so it took many hours to get this 
innocuous looking screen working. I will soon need to have a Combobox in a 
DataGrid cell and I’m not expecting that experience to be hugs and puppies 
either -- Greg

 



image001.png___
ozsilverlight mailing list
ozsilverlight@ozsilverlight.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight


RE: DataGridCheckBoxColumn

2011-12-05 Thread Steven Nagy
Disclaimer - Office365 just put your post in my ozWpf folder and that was the 
hat I was wearing when I answered. Still, should be much the same...

From: ozsilverlight-boun...@ozsilverlight.com 
[mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Steven Nagy
Sent: Tuesday, 6 December 2011 3:23 PM
To: ozSilverlight
Subject: RE: DataGridCheckBoxColumn

I love your posts Greg because there's no actual question there :)

To solve #1, Template column actually works fine and I promise it will only 
take you about 1 minute more. You get to provide your own DataTemplate which 
can contain a checkbox with the same {Binding Property} for the IsChecked 
property. Works a treat.

But yeah, I hate this problem as a whole too...

I can see you're a glass-half-full kinda guy!

From: ozsilverlight-boun...@ozsilverlight.com 
[mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Greg Keogh
Sent: Tuesday, 6 December 2011 3:19 PM
To: 'ozSilverlight'
Subject: DataGridCheckBoxColumn

So I bind some DataGrid columns and one of them is a bool which corresponds to 
a DataGridCheckBoxColumn. It all displays nicely and I get excited.

Then I notice that clicking the CheckBox cell puts it in edit mode, then I 
click it again to change the value.

Then I notice that the binding change doesn't fire until I press Enter or Tab 
or whatever to change focus. So it takes 3 gestures to change a value in a 
CheckBox column. This is unacceptable for this app.

I see many people complain about the first quirk and suggest you use a template 
column or more code and tricks as a workaround, but it all looks fragile, 
unreliable and I can see myself burning another few hours of unpaid time and it 
all probably won't work anyway.

No one seems to mention the focus problem. In WinForms you have to trap the 
cell dirty change event and commit to the data source, but there is no 
equivalent I can find. Nor does the UpdateSourceTrigger have a PropertyChanged 
value.

So I'm stuffed again.

Greg
___
ozsilverlight mailing list
ozsilverlight@ozsilverlight.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight


RE: DataGridCheckBoxColumn (fixed?!)

2011-12-05 Thread Greg Keogh
Good grief, the advice to use a template column instead of a check box
column seems to work. A single gesture is required to toggle the check and
update the bound property. Who would have guessed?!

 

Greg

 

data:DataGridTemplateColumn

  data:DataGridTemplateColumn.CellEditingTemplate

DataTemplate

  CheckBox IsThreeState=False IsChecked={Binding IsBar,Mode=TwoWay}
... /

/DataTemplate

  /data:DataGridTemplateColumn.CellEditingTemplate

/data:DataGridTemplateColumn

___
ozsilverlight mailing list
ozsilverlight@ozsilverlight.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight