EnumEditBox Item Template

Editors for WPF Forum

Posted 14 years ago by dss
Avatar
Hi,
How can I template the items in the EnumEditBox. I am using it with Flags attribute.
I need to display the items with an corresponding image.
Also can I template the selected value displayed e.g. just the images of the items selected.

Any help would be greatly appreciated.

Thanks,
Dss

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

The drop-down of the EnuEnumEditBox uses an instance of EnumListBox. The EnumListBox uses instances of EnumListBoxItem to display it's items. If you want to customize their display, you'd have to create a custom control template. If you are a WPF Studio customer you can download the default styles from our site, or if you purchased Editors for WPF separately we can send you the appropriate files. You can then take the default Style for the EnumListBoxItem and alter it to insert an image.

For the EnumEditBox, you can any number of custom items in there (including images). The PartEditBox ItemPlacement QuickStart shows how you can insert any custom items in the control. If you want to display more than one image, you could use a StackPanel with all the possible images. Then you'd need a custom IValueConverter than converts the current enumeration value to a Visibility.

Now, this is ok if you only want to use this control in one location. If you want to reuse this control in several locations, you'd probably beter off creating a derivation of EnumEditBox. In that case, you'd override GenerateDefaultItems and create the images there. You can also remove the EnumPartGroup from the defaultItems, if you just want the images.

Finally, you'd want to have a constructor like:

public class MyEnumEditBox : EnumEditBox {
public MyEnumEditBox() {
this.SetResourceReference(StyleProperty, typeof(EnumEditBox))
}
}

Without that, the MyEnumEditBox will not pick up theme changes properly.


Actipro Software Support

Posted 14 years ago by dss
Avatar
We have a WPF studio license. Could you please provide me the link to download the default styles for EnumListBoxItem.

Thanks,
Dss
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you own WPF Studio then there is a link in your Organization Purchases page to download styles right next to the main full product download link.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.