This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello,
I know it's a sour argument, I'm facing different problems with the multipleSelection, I've prepared a sample based on the SelectProperty QuickStart Solution and I've attached it here.
you can run the sample, select the 'SelectProperty' from the main menu, then click the button1, finally try to change the background color of the button.
I've tried also the nightly build, but I 've got the same error.
My problem is slightly different, but it may be the base of my problem
PS : I'm having problem attaching the file...cna I send it by email ?
|
|
|
Hi, Sorry to hear you're having some trouble. Could you email me your repro: jd@mindscape.co.nz Could you also please ensure that there are no binary files in the zip file (dlls, exes etc). If you could post a comment here once you've sent it so that I can confirm that I received the file. Thanks, John-Daniel Trask |
|
|
This was a problem with the handling of dependency properties in multiple selection. I've committed a candidate fix for this and it will be included in nightly builds dated 29 May 2009 and above. Please let us know if you run into any problems. By the way, please note that your sample won't actually be able to modify the background colour of a running button instance by changing properties of the background Brush object. In fact this will cause errors because the Brush object is frozen by this stage. The only way to change the background colour is to create a new Brush and assign that as the Background property. The property grid doesn't currently provide an easy way of doing this I'm afraid, though you might be able to do it using a PropertyEditor or a TypeEditor in WrappedValue mode. |
|
|
Ivan, thank you for the support,
would be nice if the propertygrid could have the Frozen Objects disabled in the propertygrid.
Do you have an example of already available using 'PropertyEditor or a TypeEditor' for the 'Background property' I can start with ?
|
|
|
I don't have a real example of a custom editor for WPF brushes, but here's something to get you started. Please note that this is very quick and dirty and you would want to improve the structure for production software. I will add some notes and explanations after the code. // XAML <Window.Resources> <ms:PropertyGrid> // Code behind private void EditBrush_Click(object sender, RoutedEventArgs e) The key trick here is that the TemplateBindingMode is specified as WrappedValue. Normally, TypeEditors for reference types like Brush receive a reference to the value, so they edit its properties directly. With a Freezable like Brush, we don't want to do that. Instead, to change the background of the selected object, we need to create a new Brush, and set the property to that new Brush, as if we were dealing with a value type like Int32. That's what WrappedValue does. (PropertyEditors always operate in WrappedValue mode, so if you're setting up brush editors on a per-property basis, you don't need to do this trick.) Once this is done, all that remains is for the DataTemplate to create a new Brush and update it via the Value pseudo-property. There are a number of ways you could do this depending on the desired behaviour and UI. I've imagined that you might provide a dialog box because of the range of different brush types available, but you could alternatively use a colour picker, a combo box or whatever. In my example, the dialog box is a complete fake which always returns a red SolidColorBrush, but you get the idea! Note also the use of the Tag property with a two-way binding: the code-behind sets the Tag, which is bound to the property being edited via the Value pseudo-property, so setting the Tag updates the Background or Foreground or BorderBrush or whatever. Tag is quick to use in samples, but untidy and not self-documenting, so for production code you might want to use an attached property or something. Note that some changes may be required for multiple-selection support; I haven't tested this quick sample in that environment. |
|