Tuesday, January 22, 2013

TimHeuer's FloatableWindow Issue - Setting Offset Has No Effect

TimHeuer's FloatableWindow Issue - Setting Offset Has No Effect

I have the following XAML inside a Grid named LayoutRoot.

<sdk:DataGrid x:Name="dgOrderContents" AutoGenerateColumns="False" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" AlternatingRowBackground="#FFFAEF">     <sdk:DataGrid.Columns>         <sdk:DataGridTemplateColumn Header="Thumb">             <sdk:DataGridTemplateColumn.CellTemplate>                 <DataTemplate>                     <ucp:PhotoComponentForDataGrid Source="{Binding PhotoUrl}" PopupTarget="{Binding ElementName='LayoutRoot' }" Width="60" />                 </DataTemplate>             </sdk:DataGridTemplateColumn.CellTemplate>         </sdk:DataGridTemplateColumn     </sdk:DataGrid.Columns> </sdk:DataGrid> 

PhotoComponentForDataGrid, is a UserControl, which is an image that when the user's mouse enters the image area, displays the same image, but larger using Tim Heuer's FloatableWindow, http://timheuer.com/blog/archive/2009/07/08/silverlight-floatablewindow-updated-with-resizing-capabilities.aspx

The problem I'm having is, when I try to set the position of the FloatableWindow so that the FloatableWindow is near my PhotoComponentForDataGrid control, no matter what values I use, the Window remains centered within my main Grid.

My PhotoComponentForDataGrid control has a Dependency Property named PopUpTarget which is a reference to LayoutRoot. That way when I create the FloatableWindow, I can specify the 'ParentLayoutRoot' property.

The code below is what I'm using to display my PopUp, except the X, and Y, refuse to change:

private void imgThumb_MouseEnter(object sender, MouseEventArgs e)         {             if (!this.displayingPopup)             {                 imgThumb.MouseEnter -= imgThumb_MouseEnter;                 imgThumb.MouseLeave += imgThumb_MouseLeave;                  GeneralTransform gt = imgThumb.TransformToVisual(Application.Current.RootVisual as UIElement);                 Point pt = gt.Transform(new Point(0, 0));                  try                 {                     this.popup.ParentLayoutRoot = this.PopupTarget;                     this.popup.Show(pt.X, pt.Y);                 }                 catch (Exception excep)                 {                      // Do nothing. Mouse was moved too fast.                 }                  this.displayingPopup = true;             }         } 

Thanks in advance for any help or suggestions.

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog