TextBox and Variant Size

Ribbon for WPF Forum

Posted 12 years ago by Steven S.
Version: 3.0.0405
Avatar
I'm trying to figure out how to get the variant size of a ribbon button to display the image and label on the left of it's text box. The documenation says that this is the variant when in a stackpanel and the size is set to medium.

Right now I have this textbox inside of a buttongroup that is within a rowpanel. What can I do to get to get the image and label to display in this context?

<ribbon:Group Label="Dimensions" MinWidth="50">
    <ribbon:RowPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <ribbon:ButtonGroup>
            <ribbon:TextBox Label="Width" VariantSize="Medium" MinWidth="30" ImageSourceSmall="/Resources/Images/Width16.png" ImageSourceLarge="/Resources/Images/Width32.png" />
            <ribbon:TextBox VariantSize="Medium" MinWidth="30" ImageSourceSmall="/Resources/Images/Height16.png" ImageSourceLarge="/Resources/Images/Height32.png" />
        </ribbon:ButtonGroup>
        <ribbon:CheckBox Label="Square" />
        <ribbon:CheckBox Label="Keep Ratio" />
    </ribbon:RowPanel>
</ribbon:Group>
I have tried to explicity set the Context property to see if I can get the desired effect, but it doesn't seem to matter.

<ribbon:Group Label="Dimensions" MinWidth="50">
    <ribbon:RowPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <ribbon:ButtonGroup>
            <ribbon:TextBox Label="Width" VariantSize="Medium" Context="RibbonTabGroupStackPanelItem" MinWidth="30" ImageSourceSmall="/Resources/Images/Width16.png" ImageSourceLarge="/Resources/Images/Width32.png" />
            <ribbon:TextBox VariantSize="Medium" MinWidth="30" Context="RibbonTabGroupStackPanelItem" ImageSourceSmall="/Resources/Images/Height16.png" ImageSourceLarge="/Resources/Images/Height32.png" />
        </ribbon:ButtonGroup>
        <ribbon:CheckBox Label="Square" />
        <ribbon:CheckBox Label="Keep Ratio" />
    </ribbon:RowPanel>
</ribbon:Group>
Any suggestion is greatly appreciated.

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Steven,

The ribbon:TextBox control's template is currently just showing the TextBox and not the label/image. However when contained in other controls like StackPanel or a Menu, those containers will use the label/image properties to render them. The reason for doing this is that we can achieve some complex and accurate layouts this way. For instance, in a StackPanel this allows us to align all the TextBoxes horizontally while having the labels aligned next to them, the same way Office does it.

We will look into what we can do to improve things for your scenario but in the meantime, you can wrap it with a regular WPF <StackPanel Orienatation="Horizontal"> and add an Image and TextBlock before the ribbon:TextBox. Then maybe even bind the appropriate properties on Image and TextBlock to the ribbon:TextBox.ImageSourceSmall, etc.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) 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.