title: show pop up when is mouse over image control
body: <p>I would like show pop up when is mouse over the image control.  So I create control template, it look like this:</p>
  
  <pre><code>        &lt;ControlTemplate x:Key="AvatarImageTemplate" TargetType="{x:Type Image}"&gt;
              &lt;Grid&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition&gt;&lt;/ColumnDefinition&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition&gt;&lt;/RowDefinition&gt;
                      &lt;RowDefinition&gt;&lt;/RowDefinition&gt;
                  &lt;/Grid.RowDefinitions&gt;
  
                  &lt;HERE I WANT IMAGE SOURCE  Grid.Row="0"/&gt;
                  &lt;Popup  IsOpen="False" 
                              Name="OponentImagePopUp"                               
                              AllowsTransparency="True"
                              PopupAnimation="Slide"
                              HorizontalOffset="-35"
                              VerticalOffset="0"
                              Grid.Row="1"&gt;
                      &lt;Border BorderThickness="1" 
                                  BorderBrush="Black"&gt;
                          &lt;Grid  Height="350" MinWidth="350"&gt;
                              &lt;Grid.Background&gt;
                                  &lt;LinearGradientBrush StartPoint="0,0" EndPoint="0,0.3"&gt;
                                      &lt;LinearGradientBrush.GradientStops&gt;
                                          &lt;GradientStop Color="LightGray" Offset="0"/&gt;
                                          &lt;GradientStop Color="WhiteSmoke" Offset="1"/&gt;
                                      &lt;/LinearGradientBrush.GradientStops&gt;
                                  &lt;/LinearGradientBrush&gt;
                              &lt;/Grid.Background&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="75"&gt;&lt;/ColumnDefinition&gt;
                                  &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                              &lt;/Grid.RowDefinitions&gt;
  
                              &lt;Border BorderThickness="1" 
                                      BorderBrush="Black"
                                      Background="White"
                                      Margin="4,4,4,4"
                                      Grid.Column="0"&gt;
                                  &lt;Image Margin="2,2,2,2"&gt;
                                      &lt;Image.Source &gt;
                                          &lt;MultiBinding Converter="{StaticResource avatarConverter}"&gt;
                                              &lt;Binding Path="ProfilePhoto"&gt;&lt;/Binding&gt;
                                              &lt;Binding Path="StatusInfo.IsLogged"&gt;&lt;/Binding&gt;
                                          &lt;/MultiBinding&gt;
                                      &lt;/Image.Source&gt;
                                  &lt;/Image&gt;
                              &lt;/Border&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/Popup&gt;
              &lt;/Grid&gt;
              &lt;ControlTemplate.Triggers&gt;
                  &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                      &lt;Setter TargetName="OponentImagePopUp" Property="IsOpen" Value="True" /&gt;
                  &lt;/Trigger&gt;
              &lt;/ControlTemplate.Triggers&gt;
          &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>I have two problems:</p>
  
  <ol>
  <li>I don’t how can I acces to image source in control template</li>
  <li>Also If I try make a style on Image control and set property Template -> Image control don’t have a property template.</li>
  </ol>
  
  <p>My aim is show pop pop window with same image only bigger.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I create simple control, as advice Mr. Glazkov, which have image control, here is it:</p>
  
  <pre><code>&lt;UserControl x:Class="Spirit.Controls.AvatarImageControl"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="300" d:DesignWidth="300"&gt;
      &lt;Grid&gt;
          &lt;Image x:Name="SmallImage"
              Source="{Binding ElementName=root, Path=ImageSource}"
              Stretch="Fill"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Code behind is the same:</p>
  
  <pre><code>  public partial class AvatarImageControl : UserControl
      {
          public AvatarImageControl()
          {
              InitializeComponent();
          }
  
          public ImageSource ImageSource
          {
              get { return (ImageSource)GetValue(ImageSourceProperty); }
              set { SetValue(ImageSourceProperty, value); }
          }
  
          public static readonly DependencyProperty ImageSourceProperty =
              DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(AvatarImageControl), new UIPropertyMetadata(null));
  
      }
  </code></pre>
  
  <p>I try use this contol in view:</p>
  
  <pre><code>&lt;Grid Background="#99CCFF"  Margin="4,4,4,4"&gt;
        &lt;Controls:AvatarImageControl ImageSource="{Binding Path=Oponent.Info.ProfilePhoto,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>I bind property type of Uri to ImageSource of AvatarImageControl.</p>
  
  <p>What I do bad? </p>
  
  <p>Also I try this in user control:</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;Image x:Name="SmallImage"
          Source="{Binding Path=ImageSource, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
          Stretch="Fill"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Result is same.</p>
  
  <p>I use user control in view, I bind on ImageSource property property from view model type of Uri. Nothing else.</p>
  
  <p><strong>EDIT 2:</strong>
  Code of Mr. Glazkov produce exception:</p>
  
  <pre><code>{"Set property 'System.Windows.Controls.Primitives.Popup.IsOpen' threw an exception."}
  {"A TwoWay or OneWayToSource binding cannot work on the read-only property 'IsMouseOver' of type 'System.Windows.Controls.Image'."}
  StackTrace:
     at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
     at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
     at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
     at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
     at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
     at Spirit.Controls.AvatarImageControl.InitializeComponent() in c:\Users\Jan\Documents\Visual Studio 2010\Projects\BACKUP\Pokec__Messenger\Spirit_Caliburn_Micro_v1.0\Controls\AvatarImageControl.xaml:line 1
     at Spirit.Controls.AvatarImageControl..ctor() in C:\Users\Jan\Documents\Visual Studio 2010\Projects\BACKUP\Pokec__Messenger\Spirit_Caliburn_Micro_v1.0\Controls\AvatarImageControl.xaml.cs:line 24
  </code></pre>
  
  <p>Solution is :</p>
  
  <pre><code> &lt;Popup IsOpen="{Binding ElementName=SmallImage, Path=IsMouseOver, Mode=OneWay}"&gt;
  </code></pre>
  
  <p>Set binding mode  on oneway. </p>
  
  <p>It works good.</p>
  
  <p>Thank Mr. Glazkov for help.</p>