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
|
Hi,
MainFrame.Xaml (Window) <ms:PropertyGrid Name="propertyGrid" Style="{StaticResource NormalStyle}" BorderThickness="0"> <ms:TypeEditor EditedType="{x:Type sys:String}"
...
MainResources.xaml: <ms:BuiltInEditorStyle x:Key="TextEditorStyle" EditorKey="{x:Static ms:PropertyGrid.SimpleTextEditorKey}">
... Could you tell me the correct code please ?
|
|
|
I am not quite sure what you're trying to do here, so let me offer a few suggestions. If you want to change the appearance of the "text box" editor, declare your own DataTemplate with the key {x:Static ms:PropertyGrid.SimpleTextEditorKey}. This "hijacks" the key so that the grid will find your template instead of its normal one. There are examples of this at http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1171 and http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1173. This will affect ALL users of the "text box" editor: e.g. number properties as well as strings. If you want to create a custom editor for strings (only), declare a ms:TypeEditor as you have done, but the EditorTemplate needs to refer to a DataTemplate, not a ms:BuiltInEditorStyle. NOTE: For this to work, you must set the TypeEditor's TemplateBindingMode to WrappedValue (because you wish to edit the string itself, not a property of the string), and data bind to the Value pseudo-property as if you were creating a PropertyEditor. You will need a nightly build to do this because TemplateBindingMode was added after RTM. In both of the above cases, you can put your data template in your MainResources.xaml provided this is merged into the Window.Resources or Application.Resources. If you want to style the standard text box editor when it is used for strings, but not when it is used for other types, that currently isn't directly supported. Let us know if this is what you are trying to do and we will look into adding support or suggesting a workaround. |
|
|
Thx. The problem is solved.
Now I have an other problem ;) We are using some converters (system.components.Typeconverter): For example boolen (true/false)<->(yes/no).
If I define a editor like this: ...
in the property grid you can read "true" or "false" (instead "yes" and "no") If i delete the "Editor template" I can read "yes" and "no".
How can I solve this ? |
|
|
This is working when we test it, but I may not be reproducing your configuration correctly (I am a bit confused about whether you are using a custom template EditorTemplate or modifying something using BuiltInEditorStyle). Can you send us a simple repro case? (You can attach files via the Options tab.) Thanks! |
|
|
Hi ivan,
I will try to explain it.
In a class we have an property:
[TypeConverterAttribute(typeof(SMI_Experiment_Center.Converter.YesNoTypeConverter))]
public bool AutoAccept
{
...
}
Now we have an TypeConverter:
public class YesNoTypeConverter : System.ComponentModel.TypeConverter
...
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value == null)
return null;
if (value.GetType() == typeof(string))
{
if (((string)value).ToLower() == "yes")
return true;
...
In an Window xaml file you can read:
Attachment 1 (see the file)
This works fine. In the propertygrid you can now read "yes" or "no" (also in the "propertygrid combobox")
Now i want to style the propertygrid.
Attachment 2 (see the file)
now i can read in the "property grid comboxbox" "yes" and "no" (its right) but in the propertygrid (self) true and false.
But i want also "yes" "no" in the property grid.
Second Question (another topic)
We have styled all used editors. It works fine.
But we have also an ColorEditor (your builtin editor).
How can I rewrite the template of this?
We need:
changing background color. Changing the look of the slider. Changing the look of the "open the color picker" button. ...
Add an trigger to the "open the color picker" (if mouse enter opacity =0, else animate to 1)
Is it possible ? Do you hav an sample ?
Thx again.
|
|
|
This occurs because we are doing a certain amount of magic behind the scenes in the ListSelectNoTextEntryEditor. Because you are entirely retemplating the combo box entirely, some of that magic gets bypassed and you will need to replicate it. Unfortunately there are no docs or samples on this because it shipped as part of a nightly build, but what you need to do is: * In the TextBlock that represents the "closed" part of the combo box, remove the existing Text binding and replace it with the following MultiBinding: <TextBlock.Text> * Add the following resource: <ms:ListSelectDisplayConverter x:Key="ListSelectDisplayConverter" /> You should now see Yes and No displayed in the closed part of the combo box. Basically the issue is that the simple data binding doesn't give the text block enough context to determine that there is a TypeConverter on the bound property. The MultiBinding reaches up into the editor and retrieves that additional context (the property metadata), and the converter folds the value and the property metadata together to give you the correct display. Regarding the colour editor, this is a ColorPicker control and can be templated in the usual way. The default template uses a DropDown control and two data templates, one for presenting the SelectedColor as a swatch, the other containing two tabs, one a listbox of named colours (see the NamedColor class) and the other the sliders. The key classes to look at are: DropDown, ColorPicker and NamedColor; the sliders use an internal property called NotifyingColour (which essentially simulates property change notifications on a Color object) but you probably don't need that unless you want to display synced controls for channels (e.g. text boxes and sliders). Let us know if that is important and we will look at exposing something for you. |
|
|
Thank you Ivan!
It works very well. It would by very nice if you have any sample for this.
Thx again. Mario
|
|
|
See the SimpleColourPicker style in the attached XAML file. This is very basic and ugly -- I have kept it deliberately simple so you can see the structure without getting bogged down in decorative bits -- but it should give you a starting point to apply your own visual customisations. Let me know if you need any more info.
|
|
|
Thank you very much. The sample is perfect!
|
|