Hi
I just read the Microsoft Surface Tutorial. There is the following C# sample:
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 this two methods are doing, but I never saw a method call like this:
FindChildren(this.Photos, d => d.GetType() == typeof(ScatterViewItem),
d => ((ScatterViewItem)d).Center = new Point(x,y));
This is maybe because I'm a Java programmer. So can anyone explain what this syntax is doing?