Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • How can I set a MaxWidth or (Width) on a LayoutItem Label? And make it wrap? Or use TextTrimming, so it just displays "..." at the end as it cannot fit?

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                Hello James,
                                A Label may contain different elements (not only text). To customize text, it is necessary to adjust the TextBlock that is included in the Label.Content property:

                                [XAML]
                                <dxlc:LayoutItem Name="layoutItem1"> <dxlc:LayoutItem.Label> <TextBlock Text="sdsfdsfsdfsdfdfk" TextWrapping="Wrap" MaxWidth="30"/> </dxlc:LayoutItem.Label> <dxe:TextEdit Name="textEdit1" /> </dxlc:LayoutItem>
                                Updated by Alexander Rus (2013.01.28)
                                The best approach to accomplish this task is to customize the LabelTemplate property in a Style for a LayoutItem element. Attached is a sample project that illustrates this approach.
                                Thanks,
                                Alexander Rus.

                                Q470164.zip
                                • James Baker 01.28.2013

                                  Yeah but I want to do this in a style, so is it the LabelTemplate I want to adjust?

                                  Will the AddColonToLabel and IsRequired properties still work as expected?

                                • Alexander Rus (DevExpress Support) 01.28.2013

                                  Hello James,
                                  No, in this case the AddColonToLabel and IsRequired will have no effect. But I can suggest another way to accomplish this task. You can create an attached property that finds the TextBlock used in a LayoutItemLabel and adjusts the required properties. This property can be set in a LabelStyle. I have created a sample project that demonstrates this approach and updated my answer accordingly.
                                  Thanks,
                                  Alexander Rus.

                                • Alexander Rus (DevExpress Support) 01.28.2013

                                  I addition to my previous comment, there is a better solution to accomplish this task. I suggest that you customize the LabelTemplate property in a Style for a LayoutItem element.

                                • James Baker 01.29.2013

                                  I can't find what the standard LabelTemplate is like? So I don't mess up all it does?

                                • Alexander Rus (DevExpress Support) 01.29.2013

                                  Hello James,
                                  By default, it contains a simple TextBlock. So, you can be sure that with this approach all features will be saved.

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners