Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7520297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:02:49+00:00 2026-05-30T02:02:49+00:00

I have a ListView to display log events. A style trigger is defined to

  • 0

I have a ListView to display log events. A style trigger is defined to alter the colour of the row depending on the log severity. Works ok except for one column which uses a CellTemplate. The Label items keep there normal colour.

<ListView x:Name="LogEvents" Grid.Row="0" FontSize="9">
    <ListView.ItemContainerStyle>
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="Background" Value="White"/>
            <Setter Property="Foreground" Value="Black"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Level.DisplayName}" Value="ERROR">
                    <Setter Property="Background" Value="LightSalmon"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Level.DisplayName}" Value="INFO">
                    <Setter Property="Background" Value="LightGreen"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Level.DisplayName}" Value="DEBUG">
                    <Setter Property="Background" Value="White"/>
                    <Setter Property="Foreground" Value="Gray"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Level.DisplayName}" Value="WARN">
                    <Setter Property="Background" Value="LightYellow"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Level.DisplayName}" Value="FATAL">
                    <Setter Property="Background" Value="Red"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </ListView.ItemContainerStyle>
    <ListView.View>
        <GridView x:Name="GridView1">
            <GridViewColumn Header="TimeStamp" DisplayMemberBinding="{Binding TimeStamp, ConverterCulture=de-DE, StringFormat=HH:mm:ss.fff}"/>
            <GridViewColumn  DisplayMemberBinding="{Binding Level}" Header="Level" />
            <GridViewColumn Header="Thread" DisplayMemberBinding="{Binding ThreadName}"  />
            <GridViewColumn Header="Message" DisplayMemberBinding="{Binding RenderedMessage}"  />
            <!--<GridViewColumn Header="UserName" DisplayMemberBinding="{Binding UserName}"  />-->
            <GridViewColumn Header="Class.Method">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="{Binding Path=LocationInformation.ClassName}" Padding="0"/>
                            <Label Content="." Padding="0"/>
                            <Label Content="{Binding Path=LocationInformation.MethodName}" Padding="0"/>
                            <Label Content="(" Padding="0"/>
                            <Label Content="{Binding Path=LocationInformation.LineNumber}" Padding="0"/>
                            <Label Content=")" Padding="0"/>
                        </StackPanel>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
        </GridView>
    </ListView.View>
</ListView>

For example, if the Level=Debug, the ‘Class.Method’ column receives the appropriate Background (LightGrey) but the Forground remains Black (default).

What do I have to do here? Repeat the Style.Triggers for x:Type Labels?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:02:52+00:00Added an answer on May 30, 2026 at 2:02 am

    This worked. Not sure if there is a nicer way but it is fairly compact.

    <GridViewColumn.CellTemplate>
         <DataTemplate>
            <!-- Added this section so Label inherits from Parent ListViewItem -->
            <DataTemplate.Resources>
                <Style TargetType="{x:Type Label}">
                    <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=Background}"/>
                    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=Foreground}"/>
                </Style>
            </DataTemplate.Resources>
            <StackPanel Orientation="Horizontal">
               <Label  ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView where I would like to display things horizontally. That works
I have a listview and want to change its style to display:none on pageload
I have a ListView which is using a GridView to display a DataTable and
I have an ASP ListView, and have a very simple requirement to display numbers
i want to display some information in a listview using the GridView. i have
I have an app using a ListView as a main screen. Each row displays
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a custom listview and I am using a custom listadapter to display
Microsoft I think this may be a bug. Have a ListView GridView to display
I have ObservableCollection for my Collection og Movie files. Im using ListView to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.