0

Iam working in a WPF Application and in one place I had to use this piece of code to get the reference to a VirtualizingStackPanel.

Following is the piece of code,

VirtualizingStackPanel vsp = (VirtualizingStackPanel)obj.InvokeMember("_itemsHost", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, content, null);

vsp.SetVerticalOffset(_SomeSelectedIndex);

Can someone explain what exactly this lines do and what are those binding flags ?

Sheridan
  • 68,826
  • 24
  • 143
  • 183
surajitk
  • 147
  • 4
  • 21
  • 2
    look here for BindingFlags http://msdn.microsoft.com/en-us/library/system.reflection.bindingflags(v=vs.110).aspx – potehin143 Feb 04 '14 at 05:58
  • 1
    here is about what Type.InvokeMember do http://msdn.microsoft.com/en-us/library/66btctbe(v=vs.110).aspx with exapmles – potehin143 Feb 04 '14 at 06:05
  • Thanks. It helped. here's one more source to get the complete idea http://stackoverflow.com/questions/5056728/can-i-access-itemshost-of-itemscontrol-using-reflection – surajitk Feb 04 '14 at 07:20
  • And VirtualizingStackPanel.setVerticalOffset() Scrolls the items to a specific index. – surajitk Feb 04 '14 at 07:22

0 Answers0