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
|
I'm using the DropDownEditBox in a custom PropertyEditor in my PropertyGrid. I also use the DropDownDatePicker and TimePicker controls, both of which use the DropDownEditBox for their displays, for editing some properties. When I use a theme (e.g., Alloy), the toggle buttons on all of these match the look of the toggle button on a ComboBox (like the one used for Boolean properties). However, when I use the generic theme, the toggle button on the DropDownEditBox (and the controls that use it) appears with an inverted triangle in the center whereas the ComboBox's toggle button appears with a wide "v" in the middle. I've attached an image of the two types of toggle buttons. The top half shows a DropDownEditBox and a regular ComboBox (for a Boolean property) in a PropertyGrid. Under that is a standard ComboBox. The lower half shows a standard ComboBox with a PropertyGrid below it containing two DateTime properties, each with a DropDownDataPicker for the date on the left and a TimePicker for the time on the right. Under these is another Boolean property editor's ComboBox. How can I style the DropDownEditBox's toggle button so it matches the one on the ComboBox? Thanks, BillBR |
|
|
Hello BillBR The generic style is only applied to the WPF Elements control. All the standard WPF controls pick up the generic style from the operating system. So one thing to keep in mind is that the combo boxes will look different on different operating systems, so you may also want to create a ComboBox style so you always have full control of the consistency of the styles. In any case, to style the DropDownEditBox put this code in your resource dictionary:
The top style is the drop down button style, and the bottom style is the DropDownEditBox control which hosts the drop down button, the popup and the header content. Since the DropDownEditBox style does not set the x:Key, this style will be picked up by all DropDownEditBox controls in your application including those used by the DropDownDatePicker and others. This is the OfficeBlue DropDownEditBox style. You can use this as a starting place for your own style, or look through the *.Common.xaml files in the Themes directory to pick a different theme to start from. I recommend starting by changing only one thing such as the background color of the drop down button to first make sure the style is being picked up in your application. Jason Fauchelle |
|
|
Thanks for getting back to me on this, Jason. I'm a bit confused by your response though. I want to use the Generic theme and make all the DropDownEditBox toggle buttons in my app look like the toggle buttons on the standard ComboBox (for whatever operating system the app is running on). It doesn't look like there's an easy way to do that, since I can't easily hijack the style of the ComboBox's toggle button for use with the DropDownEditBox (for example using BasedOn). However, the code you posted here did get me pointed in the right direction for a partial solution that works reasonably well for me. My app will probably not be run on platforms other than Win8, so I can get by with just a single template for the toggle button. (Otherwise I'd need a mechanism to handle platform-specific templates and a way to select the appropriate one.) To get it to work, I copied the style for the DropDownEditBox from Generic.xaml into my own resource dictionary. I also added the Style tag for the ToggleButton from your code, removing all the setters except the one for OverridesDefaultStyle. I added a setter for the Template property and a pair of tags for the Setter.Value. I then separately generated the style for the standard ComboBox (I used a utility that I wrote, but Blend probably works as well) and copied the entire tag for the ControlTemplate with the TargetType="ToggleButton" into the Setter.Value of my own Template property. With very little clean up, it worked just fine for the DateTimePicker. Now its toggle buttons look just like the ones for the regular ComboBox. One thing I noticed while doing this is that the TimePicker (which I also use) does not actually use the DropDownEditBox even though it has a ToggleButton on it. To make it appear like the standard ComboBox's toggle button, I copied its Style from Generic.xaml and replaced its ToggleButton tag with the same code I had used for the DropDownEditBox replacement. Now the TimePicker toggle button uses the same ToggleButton style and looks the same as the others. Suggestion: Set the Style for the ToggleButton in the TimePicker control to bind to the same DropDownEditBox.ToggleButtonStyleKey static resource as the one in the DropDownEditBox does. Thanks once again, BillBR |
|
|
Thanks for this suggestion BillBR, I've noted it down for the next version. Indeed you can not hijack the ComboBox style from the operating system as the DropDownEdit box doesn't use anything related to the ComboBox control - it has it's own toggle button style. If your application will mostly run on Win8 devices, then it's probably not important to do anything about it for now. Jason Fauchelle |
|