EnumEditbox/EnumListBox features

Editors for WPF Forum

Posted 14 years ago by Martin - Blaise - Statistics Netherlands
Version: 9.2.0514
Avatar
Good Morning:)

In my ribbon i added an EnumEditBox for the Scope of searching a document.
            <editors:EnumEditBox x:Name="ScopeListBox" 
                                 Value="{Binding Path=Scope}"
                                 MinWidth="100"
                                 IsEditable="False"
                                 EnumType="{x:Type se:EditorSearchScope}"
                                 UseDescriptionAttributes="True"
                                 />
I was hoping that the items would have a tooltip with the description, or do i have to make an Item template?

BTW, how can i stretch the box horizontally?

And how can i limit the number of dropdownitems (or the size of the dropdownbox)? Usage of MaxDropDownHeight doesn't seems to matter.

Is it possible to stack the items of an EnumListbox horizontally?

Regards

Martin

[Modified at 03/01/2010 04:44 AM]

Comments (3)

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

To add a ToolTip with description, you could use an implicit Style for the EnumListBoxItem type, like so:
<Style x:Key="{x:Type editors:EnumListBoxItem}" TargetType="{x:Type editors:EnumListBoxItem}"
    BasedOn="{StaticResource {x:Type editors:EnumListBoxItem}}">
    <Setter Property="ToolTip" Value="<insert tooltip>" />
</Style>
You could leverage our EnumDescriptionConverter, but you would have to create a class that derives from it and passes typeof(string) as the targetType. Then you'd use a binding like "{Binding Converter={StaticResource MyEnumDescriptionConverter}}".

You should be able to set the Width/Height of the popup, including the min/max values. For EnumEditBox, the default Style sets the MinDropDownHeight to 150. So if you try to use a MaxDropDownHeight smaller than that, you'd need to set MinDropDownHeight to a lower value.

The drop-down doesn't currently support dynamic resizing, but you could accomplish that by setting the EnumEditBox.DropDownContentTemplate property, using a shared:ResizableContentControl. You can take the default Style for EnumEditBox and just wrap it with ResizableContentControl.

You can change the ItemsPanel for the EnumListBox, just like a regular ListBox. Then you can specify a StackPanel that is oriented horizontally.


Actipro Software Support

Posted 14 years ago by Martin - Blaise - Statistics Netherlands
Avatar
Well, made a converter like this:
    public class EditorSearchScopeValueConverter : ActiproSoftware.Windows.Data.EnumDescriptionConverter, IValueConverter {

        #region IValueConverter Members

        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            return base.Convert(value, typeof(string), parameter, culture);
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            return base.ConvertBack(value, typeof(ActiproSoftware.Windows.Controls.SyntaxEditor.EditorSearchScope), parameter, culture);
        }

        #endregion
    }
, bound the tooltip like this:
        <lang:EditorSearchScopeValueConverter x:Key="EditorSearchScopeValueConverter" />
        <Style x:Key="{x:Type editors:EnumListBoxItem}" TargetType="{x:Type editors:EnumListBoxItem}"
                BasedOn="{StaticResource {x:Type editors:EnumListBoxItem}}">
            <Setter Property="ToolTip" Value="{Binding Converter={StaticResource EditorSearchScopeValueConverter}}" />
        </Style>
but to no reveal:) The tooltip is shown, but contains just the name of the enum item, not the description.

Maybe i am mistaken, but does ActiproSoftware.Windows.Controls.SyntaxEditor.EditorSearchScope have a description attribute?;)
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

Sorry, I missed the part where you were using the SyntaxEditor.EditorSearchScope. That type (nor do our other enum types) does not specify a DescriptionAttribute. What you could do is have your IValueConverter switch on the value (which is a EditorSearchScope), and return a custom string.


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.