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 7754425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:18:16+00:00 2026-06-01T12:18:16+00:00

I am new here and hope my first question meets stack overflow’s requirements. I

  • 0

I am new here and hope my first question meets stack overflow’s requirements. I have done some research so far but could not figure it out myself.
I create a UserControl (derived from an intermediate base Class) which should be able to change a color sign to a different color depending on its “VisualAlarmState” Property which is a DependencyProperty.
The Style plus ControlTemplate are rendered as expected but the DataTrigger at the end of the style does not change the color (=image) of VisualAlarmSign which is an Image element.
The code can be compiled and run without errors but the alarm state will not be shown as expected.

Something I do ot really understand either: I have to reference the Style dynamically because Style=”{StaticResource DashboardItemStyle}” will be underlinded and at mouse hover says: “The resource “DashboardItemStyle” could not be resolved.”

<ucbase:DashboardItemBase.Resources>
            <BitmapImage x:Key="MO-Zylinderdeckel" UriSource="/ModuleDashboard;component/Resources/MO-Zylinderdeckel.tif" />
            <BitmapImage x:Key="MO-Zylindermantel" UriSource="/ModuleDashboard;component/Resources/MO-Zylindermantel.tif" />
            <BitmapImage x:Key="MO-Zylinderboden" UriSource="/ModuleDashboard;component/Resources/MO-Zylinderboden.tif" />
            <BitmapImage x:Key="MO-Marker-Grün" UriSource="/ModuleDashboard;component/Resources/MO-Marker-Grün.tif" />
            <BitmapImage x:Key="MO-Marker-Orange" UriSource="/ModuleDashboard;component/Resources/MO-Marker-Orange.tif" />
            <BitmapImage x:Key="MO-Marker-Rot" UriSource="/ModuleDashboard;component/Resources/MO-Marker-Rot.tif" />

    <Style x:Key="DashboardItemStyle" TargetType="{x:Type ucbase:DashboardItemBase}">

        <Setter Property="Template" x:Name="Template1">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ucbase:DashboardItemBase}">                        
                    <dxlc:Tile x:Name="Tile" Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1"
                            Height="128.5" Width="208.5" Background="{x:Null}">
                        <dxlc:Tile.Content>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="11.5" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="12.5" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="6.5" />
                                </Grid.ColumnDefinitions>

                                <Image Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1"
                                        HorizontalAlignment="Stretch" Stretch="Fill" VerticalAlignment="Stretch"
                                        Source="{StaticResource MO-Zylinderdeckel}" />

                                <Grid Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="1">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="6.5" />
                                    </Grid.ColumnDefinitions>
                                    <Image Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="1" Grid.RowSpan="2"
                                            HorizontalAlignment="Stretch" Stretch="Fill" VerticalAlignment="Stretch"
                                            Source="{StaticResource MO-Zylindermantel}" />


                                        <Image x:Name="VisualAlarmSign" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Height="14"
                                            Margin="0,20,0,0" Width="19.5" HorizontalAlignment="Right"
                                            VerticalAlignment="Top" Source="{StaticResource MO-Marker-Grün}" />
                                </Grid>

                                <Image Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="3" Grid.RowSpan="1"
                                        HorizontalAlignment="Stretch" Stretch="Fill" VerticalAlignment="Stretch"
                                        Source="{StaticResource MO-Zylinderboden}" />
                            </Grid>
                        </dxlc:Tile.Content>
                    </dxlc:Tile>

                    <ControlTemplate.Triggers>

                        <!-- This Trigger has no effect. Why?-->
                        <DataTrigger
                                Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=VisualAlarmState}">
                            <DataTrigger.Value>
                                <vmbase:AlarmState>Alarm</vmbase:AlarmState>
                            </DataTrigger.Value>
                            <Setter TargetName="VisualAlarmSign" Property="Source"
                                    Value="{StaticResource MO-Marker-Rot}" />
                        </DataTrigger>                      </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ucbase:DashboardItemBase.Resources>

Working Solution

I removed Source={StaticResource MO-Marker-Grün} from the <Image> element and I moved the <DataTrigger> from <ControlTemplate.Triggers> to <Style.Triggers> in <Image.Style> which resulted in the following XAML code:

<ucbase:DashboardItemBase.Resources>
    ...
    <BitmapImage x:Key="MO-Marker-Rot" UriSource="/ModuleDashboard;component/Resources/MO-Marker-Rot.tif" />
    ...
        <Style x:Key="DashboardItemStyle" TargetType="{x:Type ucbase:DashboardItemBase}">
            <Setter Property="Template" x:Name="Template1">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ucbase:DashboardItemBase}">                        
                        <dxlc:Tile x:Name="Tile" Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1"
                                Height="128.5" Width="208.5" Background="{x:Null}">
                            <dxlc:Tile.Content>
                                <Grid>
                                    ...                                     
                                    <Image x:Name="VisualAlarmSign" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0"
                                            Height="14" Margin="0,20,0,0" Width="19.5" HorizontalAlignment="Right"
                                            VerticalAlignment="Top" >
                                        <Image.Style>
                                            <Style>
                                                <Style.Triggers>
                                                    <DataTrigger
                                                            Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=VisualAlarmState}"
                                                            Value="Alarm">
                                                        <Setter Property="Image.Source"
                                                                Value="{StaticResource MO-Marker-Rot}" />
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Image.Style>
                                    </Image>
                                    ...
                                </Grid>
                            </dxlc:Tile.Content>                        
                        </dxlc:Tile>                        
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
</ucbase:DashboardItemBase.Resources>
  • 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-06-01T12:18:17+00:00Added an answer on June 1, 2026 at 12:18 pm

    Try setting the source of image using style property setter. Some how trigger behave wired.

    <Image x:Name="VisualAlarmSign" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Height="14"
                                                Margin="0,20,0,0" Width="19.5" HorizontalAlignment="Right"
                                                VerticalAlignment="Top">
        <Image.Style>
        <Style>
         <Setter TargetName="VisualAlarmSign" Property="Source"
                                            Value="{StaticResource MO-Marker-Grün}" />
        </Style>
        </Image.Style>
    </Image>
    

    Make sure to remove the source property in the image tag.

    Some how triggers may not set properties we have used in the tag. in your case you set the value of source in the image tag. if you set the same value through style setter it may worm. its worth a try.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

thats my first question here and i hope someone can help me. I´m new
This is the first time i'm asking a question here at stack overflow so
I'm new here and I hope anyonte can help me. I have WCF Service
I'm new here and I hope I could get some help with an Android
First question on stackoverflow :) Hope I won't embarrass myself... I have a javascript
This is my first question here, so I hope that I am providing enough
this is my first question here so I hope I'm doing this right. I
this is my first question here. I hope dont make any mistake, be good
My first question here and i'll try to be specific. I am quite new
Here's my new question: On a search results page we have 12 products shown.

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.