private void InitializeSpecifiedGameField(Button gameFieldButton, int index) { gameFieldButton.Style = (Style)resourceDictionary["gameFieldButtonStyle"]; gameFieldButton.SetValue(ControlExtensions.IsSelectedProperty, false); gameFieldButton.SetValue(ControlExtensions.IndexProperty, index); Binding binding = new Binding("Index") { RelativeSource = new RelativeSource(RelativeSourceMode.Self) }; gameFieldButton.Command = ButtonSelectedCommand; gameFieldButton.CommandParameter = ControlExtensions.GetIndex(gameFieldButton); gameFieldButton.Visibility = Visibility.Visible; }