Question

Wordwrap in Ribbon Button

Posted 24 days ago by Avatar Stefan Link

Is it possible to get a word wrap for special characters like '-' within a ribbon button (like i can get within a TextBlock)?

Sample:

public class MainViewModel
{
    public string ShortLabel => "T-S";
    public string ShortLabelWithSpace => "T- S";
    public string ShortLabelWithNonVisibleSpace => "T-\u200BS";
    public string LongLabel => "Test-String";
    public string LongLabelWithSpace => "Test- String";
    public string LongLabelWithNonVisibleSpace => "Test-\u200BString";
}
<Window.DataContext>
    <viewModel:MainViewModel />
</Window.DataContext>

<DockPanel>

    <ribbon:Ribbon DockPanel.Dock="Top">
        <ribbon:Tab Label="TEST">
            <ribbon:Group Label="Test Group">
                <ribbon:Button Label="{Binding ShortLabel}" />
                <ribbon:Button Label="{Binding ShortLabelWithSpace}" />
                <ribbon:Button Label="{Binding ShortLabelWithNonVisibleSpace}" />
                <ribbon:Button Label="{Binding LongLabel}" />
                <ribbon:Button Label="{Binding LongLabelWithSpace}" />
                <ribbon:Button Label="{Binding LongLabelWithNonVisibleSpace}" />
            </ribbon:Group>
        </ribbon:Tab>

    </ribbon:Ribbon>

    <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding ShortLabel}" Width="50" TextWrapping="Wrap" />
        <TextBlock Text="{Binding ShortLabelWithSpace}" Width="50" TextWrapping="Wrap" />
        <TextBlock Text="{Binding ShortLabelWithNonVisibleSpace}" Width="50" TextWrapping="Wrap" />
 
        <!-- This is the case that's not working -->	  
        <TextBlock Text="{Binding LongLabel}" Width="50" TextWrapping="Wrap" />
	
	<!-- Ugly if the text is too short and no line break occurs (see short label example) -->  
        <TextBlock Text="{Binding LongLabelWithSpace}" Width="50" TextWrapping="Wrap" /> 

	<!-- Special space character also doesn't work -->  
        <TextBlock Text="{Binding LongLabelWithNonVisibleSpace}" Width="50" TextWrapping="Wrap" />
    </StackPanel>
</DockPanel>
Information The latest build of this product (2018.1 build 0672) was released 27 days ago, which was before this thread was created.

Comments (2)

Posted 24 days ago by Actipro Software Support - Cleveland, OH, USA

Hi Stefan,

We currently support wrapping via the "WithSpace" examples but not the other two. 

We have made a code update for the next build to allow the "WithNonVisibleSpace" examples as well. 

We can't do the other one (no space) though because the buttons only allow two lines and we need to know where a possible break should occur.  We look for whitespace characters to know where those breaks can be.


Actipro Software Support
Posted 19 days ago by Stefan Link

Thanks, even the small changes help a lot!


Add a Comment

Please log in to a validated account to post comments.