Wordwrap in Ribbon Button

Ribbon for WPF Forum

Posted 1 year ago by Stefan Link
Version: 17.2.0665
Avatar

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>

Comments (2)

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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 1 year ago by Stefan Link
Avatar

Thanks, even the small changes help a lot!

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.