Can't change colours in WPF MIP after theme is applied

Hi,

i’m developing a MIP in WPF, but after the theme is applied i can’t change colours of text or background.

For example if i set a data trigger to a listview for change background and foregroung of a row, the foreground remain white

<ListView Name="lvwAttaches" Foreground="Black" Grid.Row="0" Grid.Column="0" ItemsSource ="{Binding Attaches}" SelectionChanged="lvwAttaches\_SelectionChanged" MouseDoubleClick="lvwAttaches\_MouseDoubleClick">

  <ListView.View>

    <GridView>

      <GridViewColumn Header="{DynamicResource IPViewLPP.Client.CtrlAttaches.ColFileName}" DisplayMemberBinding="{Binding FileName}" />

      <GridViewColumn Header="{DynamicResource IPViewLPP.Client.CtrlAttaches.ColType}" DisplayMemberBinding="{Binding AttachType}" />

      <GridViewColumn Header="{DynamicResource IPViewLPP.Client.CtrlAttaches.ColExpiration}" DisplayMemberBinding="{Binding DtScadenza}" />

      <GridViewColumn Header="{DynamicResource IPViewLPP.Client.CtrlAttaches.ColDescription}" DisplayMemberBinding="{Binding Description}" />

    </GridView>

  </ListView.View>

  <ListView.ItemContainerStyle>

    <Style TargetType="ListViewItem">

      <Setter Property="BorderBrush" Value="LightGray" />

      <Setter Property="BorderThickness" Value="0,0,0,1" />

      <Style.Triggers>

        <DataTrigger Binding="{Binding CheckScadenza}" Value="1">

          <Setter Property="Background" Value="LightYellow"/>

          <Setter Property="Foreground" Value="Red"/>

        </DataTrigger>

        <DataTrigger Binding="{Binding CheckScadenza}" Value="2">

          <Setter Property="Background" Value="LightYellow"/>

          <Setter Property="Foreground" Value="Red"/>

        </DataTrigger>

        <DataTrigger Binding="{Binding CheckScadenza}" Value="3">

          <Setter Property="Background" Value="LightYellow"/>

          <Setter Property="Foreground" Value="Red"/>

        </DataTrigger>

        <Trigger Property="IsSelected" Value="True">

          <Setter Property="Foreground" Value="Red"/>

        </Trigger>

        <!-- Aggiungi altri trigger per altri stati se necessario -->

      </Style.Triggers>

    </Style>

  </ListView.ItemContainerStyle>

</ListView>

this is the result., After the theme is applied by XPClient, it overrides all directives and i can’t change some control’s attributes.

Thank’s advance

Gian-Luca

I consulted Milestone Development..

-

The problem you face here is not related to the MIP or the Smart Client especially, it is a general WPF “problem”.

When you create a style for their ListViewItem you are setting properties on that Item, not on a TextBlock directly.

What happens is that the ListViewItem is created, then it creates a TextBlock inside because there is some text (or maybe a style creates that Textblock). The TextBlock then pulls the style for a TextBlock and ignores what is set in the custom ListViewItem style you have created.

There are MANY questions/examples online about this and I might not have found the perfect one, but the one here at least explains the same issue with a button.

https://stackoverflow.com/questions/17414047/wpf-cannot-override-button-conent-foreground

Since we don’t have a full sample I cannot say exactly what the fix for you is here (and you might be able to work it out yourself), but maybe you can try and set “TextBlock.Foreground” instead of Foreground, that might work. But it depends on a case by case basis what is the correct solution.