Bug Report T263701
Visible to All Users

Setting ListBoxEditItem's foreground in ListBoxEdit's ItemContainerStyle has no effect

created 10 years ago

In version 14.2.7 this code functioned as expected, to fix an issue with the default theme where the foreground and background were both White.
<dxe:ListBoxEdit.ItemContainerStyle>
    <Style BasedOn="{StaticResource {x:Type dxe:ListBoxEditItem}}" TargetType="{x:Type dxe:ListBoxEditItem}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="Black" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="False">
                <Setter Property="Foreground" Value="Black" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Foreground" Value="White" />
            </Trigger>
        </Style.Triggers>
    </Style>
</dxe:ListBoxEdit.ItemContainerStyle>

However once we upgraded to 14.2.8, only the HorizontalContentAlignment setter was being observed.
We had to change the ItemTemplate to facilitate the same behavior (while keeping the style for the horizontal alignment).
<dxe:ListBoxEdit.ItemTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding}">
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="Black" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter Property="Foreground" Value="Black" />
                        </Trigger>
                        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type dxe:ListBoxEditItem}}}" Value="True">
                            <Setter Property="Foreground" Value="White" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
        </TextBlock>
    </DataTemplate>
</dxe:ListBoxEdit.ItemTemplate>

This wasn't something listed in your breaking changes. Please fix. Thank you.

Comments (3)
Kirill (DevExpress Support) 10 years ago

    Hello,
    I have reproduced this issue and forwarded it to our R&D team for further research. Follow our notifications to be informed about our progress.
    As a workaround, you can set ListBoxEdit's AllowItemHighlighting property to "True". I have attached a sample project to demonstrate this approach.

    Thanks,
    Kirill

    GK GK
    Greg Kwiatkowski 1 10 years ago

      Any word? Or where are these notifications that which you speak of?

      Andrey Marten (DevExpress Support) 10 years ago

        Hello Greg,

        Our developers are working on the issue. As soon as we have any news, we will update this thread. We appreciate your understanding.

        Thanks,
        Andrey

        Answers approved by DevExpress Support

        created 9 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          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.