code_junkie

How can I obtain the coordinates of a selected item container in a WPF ListView

Nov 11th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <ListView
  2. x:Name="TechSchoolListView"
  3. ClipToBounds="False"
  4. Width="Auto" Height="Auto"
  5. HorizontalContentAlignment="Stretch"
  6. VerticalContentAlignment="Top"
  7. ItemTemplate="{DynamicResource TechSchoolDataTemplate}"
  8. ItemsSource="{Binding Path=TechSchoolResearchList, Mode=Default}"
  9. SelectedIndex="1"
  10. SelectedValue="{Binding Path=SelectedTechSchool, Mode=Default}"
  11. SelectionChanged="TechSchoolList_SelectionChanged"
  12. ItemContainerStyle="{DynamicResource TechSchoolItemContainerStyle}"
  13. ScrollViewer.CanContentScroll="False"
  14. ScrollViewer.VerticalScrollBarVisibility="Disabled" >
  15. <ListView.Background>
  16. <SolidColorBrush Color="{DynamicResource PanelBackgroundColor}"/>
  17. </ListView.Background>
  18. </ListView>
  19.  
  20. UIElement selectedContainer = (UIElement) TechSchoolListView.ItemContainerGenerator.ContainerFromIndex(TechSchoolListView.SelectedIndex);
  21. Point cursorPos = selectedContainer.TranslatePoint(new Point(selectedContainer.DesiredSize.Width, 0.0), Page);
  22. PanelCursor.Height = selectedContainer.DesiredSize.Height;
  23. PanelCursor.Margin = new Thickness(400, cursorPos.Y, 0.0, 0.0);
Add Comment
Please, Sign In to add comment