I just read a tutorial on Microsoft Surface. The following C # sample exists:
private void OnCenterItems(object sender, RoutedEventArgs e) { var x = this.Photos.ActualWidth / 2; var y = this.Photos.ActualHeight / 2; FindChildren(this.Photos, d => d.GetType() == typeof(ScatterViewItem), d => ((ScatterViewItem)d).Center = new Point(x,y)); } private void FindChildren(DependencyObject source, Predicate<DependencyObject> predicate, Action<DependencyObject> itemFoundCallback) { int childCount = VisualTreeHelper.GetChildrenCount(source); for (int i = 0; i < childCount; i++) { DependencyObject child = VisualTreeHelper.GetChild(source, i); if (predicate(child)) { itemFoundCallback(child); } FindChildren(child, predicate, itemFoundCallback); } }
I think I understand more or less what these two methods do, but I have never seen a method call like this:
FindChildren(this.Photos, d => d.GetType() == typeof(ScatterViewItem), d => ((ScatterViewItem)d).Center = new Point(x,y));
Perhaps this is because I am a Java programmer. So can anyone explain what this syntax does?
anon
source share