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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:43:46+00:00 2026-06-16T15:43:46+00:00

I have a datatemplate used for datagridtemplatecolumn I am trying to show different image

  • 0

I have a datatemplate used for datagridtemplatecolumn
I am trying to show different image on mouse over in Image.
On mouse over, the cursor is changing but image is not changing.

 <DataTemplate x:Key="MyDataTemplate" DataType="DataRowView">
        <StackPanel Orientation="Horizontal" Background="Transparent">
            <Image Margin="0,0,0,0"   Width="50" Height="50" Source="{Binding Converter={StaticResource SetImgToDG}}" ToolTip="{Binding}" >
                <Image.Resources>
                    <Style TargetType="{x:Type Image}">
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <!-- Hover image -->
                                <Setter Property="Cursor" Value="Hand"/>
                                <Setter Property="Source" Value="C:\Images\Coil3.png"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </Image.Resources>
            </Image>
        </StackPanel>
    </DataTemplate>  

Is that binding creates the problem??
How to resolve it??

  • 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-16T15:43:47+00:00Added an answer on June 16, 2026 at 3:43 pm

    Your problem is that the initial source of the image is defined directly on the Source property of the image instance.

    When there are multiple things that try to set the value of a dependency property, the framework has to decide which value to use.

    In your case the value is being set directly on the image instance (locally) and also by a Trigger.
    The local value will always win in this case, so nothing happens when the Trigger is activated.

    If you set the initial value in the style instead, the Trigger will win when it tries to change the image source, and that will make the image change when the mouse hovers over it.

    You can read more about how the value of a Dependency Property is being resolved on MSDN.

    <Image.Resources>
        <Style TargetType="{x:Type Image}">
            <!-- Set the initial source in the style so the trigger can change it -->
            <Setter Property="Source" Value="{Binding Converter={StaticResource SetImgToDG}}" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <!-- Hover image -->
                    <Setter Property="Cursor" Value="Hand"/>
                    <Setter Property="Source" Value="C:\Images\Coil3.png"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Image.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTemplate that is used by a listbox: <local:BooleanToFontColorConverter x:Key=boolToFontColor /> <DataTemplate
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I have a DataTemplate containing an Image. To the Image I added a ContextMenu
I have the following DataTemplate : <DataTemplate x:Key=ColoringLabels> <TextBlock Padding=0 Margin=0 Name=Username Text={Binding Username}
So I have the following DataTemplate for a ListBox.ItemTemplate : <DataTemplate x:Key=Tweet> <Grid> <Grid.ColumnDefinitions>
I have a databound TextBlock control (which is being used inside a DataTemplate to
I have a DataTemplate that is defined in App.xaml and is used in 2
I have a ContextMenu (from the Silverlight Toolkit) inside a DataTemplate used as the
I'm having some problems changing the DataTemplate that is used for a TreeViewItem when
I have a usercontrol I have created. It is used within the DataTemplate of

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.