Tadek

Tadek

  • NA
  • 5
  • 5.3k

absolute position(x,y) of ListBoxItem - Binding self , IValueConverter and TransformToVisual - is it possible?

Mar 8 2011 11:38 AM
Hi,


I'm trying something like this:
 
....
<DataTemplate...> 
....
        <TextBlock Text="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource PositionConverter}}" />


and


class Position : IValueConverter
{

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
  GeneralTransform generalTransform = value.TransformToVisual(null);     // here I get error
Point point = generalTransform.Transform(new Point());

return "X="+Point.X+"Y="+Point.Y;
  }
....


and the result is following error:  'object' does not contain a definition for 'TransformToVisual' and no extension method 'TransformToVisual' accepting a first argument of type 'object' could be found 


Any ideas how to solve this, or maybe some one know different approach to get absolute position of listbox elements?

Regards,
Tadek.



Answers (4)