private int Recalculate() { int value = 0; var buttons = EditGrid.FindChildren <ToggleButton>(); foreach (var button in buttons) { if (button.IsChecked == true) { value |= button.TabIndex; } } return(value); }
private void Set(int value) { if (value > 255) { value = 255; } if (value < 0) { value = 0; } var buttons = EditGrid.FindChildren <ToggleButton>(); foreach (var button in buttons) { button.IsChecked = false; if (value - button.TabIndex >= 0) { value -= button.TabIndex; button.IsChecked = true; } } }