void layers_LayerVisibilityChanged(object sender, LayerChangedEventArgs e) { foreach (var checkBox in LayersStack.Children.Cast <UIElement>() .OfType <CheckBox>() .Where(checkBox => Grid.GetColumn(checkBox) == 2 && checkBox.Tag.ToString() == e.LayerName)) { checkBox.IsChecked = layers.IsVisible(layers[e.LayerName]); } }