Ticket T813646
Visible to All Users

ListBoxEdit - How to horizontally stretch custom content from ItemTemplate

created 6 years ago (modified 6 years ago)

Hello,
im customizing my item template like this

XAML
<dx:ListBoxEdit.ItemTemplate> <DataTemplate> <dxlc:LayoutGroup Orientation="Horizontal"> <dxlc:LayoutItem Label="{x:Static p:KundenResources.supplierGroup}"> <TextBlock Text="{Binding Lieferantengruppe}"/> </dxlc:LayoutItem> <dxlc:LayoutItem Label="bis"> <dx:DateEdit EditValue="{Binding bis}"/> </dxlc:LayoutItem> <dxlc:LayoutItem Label="eyo"> <dx:DateEdit EditValue="{Binding von}"/> </dxlc:LayoutItem> </dxlc:LayoutGroup> </DataTemplate> </dx:ListBoxEdit.ItemTemplate>

It does not stretch to the screen width as i would want.
I actually already snooped it and found that, if i set the contentpresenter to stretch, i get the desired result (see Attachment)
But i have no idea how i would go about incorporating that into my xaml.

Additionally i just noticed that if an item is selected and i go from an empty dateedit to picking a date, the item is suddenly unselected.

Answers approved by DevExpress Support

created 6 years ago (modified 6 years ago)

Hello,

This behavior is not specific to ListBoxEdit. You can see the same behavior in the standard ListBox: How to get a ListBox ItemTemplate to stretch horizontally the full width of the ListBox?.

You can use one of these approaches to stretch the content of ListBoxEditItems:

1. Set ListBoxEdit's HorizontalContentAlignment to Stretch;
2. Declare a custom ItemContainerStyle:

XAML
<dxe:ListBoxEdit.ItemContainerStyle> <Style TargetType="dxe:ListBoxEditItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> </Style> </dxe:ListBoxEdit.ItemContainerStyle>

I should also note that we strongly advise against using LayoutGroups and LayoutItems outside the LayoutControl (see: LayoutGroup Class). Wrap your LayoutGroup with the LayoutControl to avoid possible side effects in the future.

Thanks,
Andrey

    Comments (3)

      Hello,

      i kinda made it work. You have to set HorizontalContentAlignment directly in the ListBoxEdit.
      Though i realized stretch wasnt what i wanted.

      Can you turn my last sentence in a different ticket? Or answer it i dont mind either way.

      Andrey Marten (DevExpress Support) 6 years ago

        Hello,

        I've extracted your additional question to a separate ticket: T813889 - ListBoxEdit - A selected item is unselected when its internal DateEdit is edited. Let's continue our discussion there.

        Thanks,
        Andrey

        Andrey Marten (DevExpress Support) 6 years ago

          Just a follow-up.
           
          I've added the information about the HorizontalContentAlignment property in the ListBoxEdit to my answer so that other customers can find it more easily. Thank you for pointing this out.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.