private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (_isNewInstance) { NumbersOfNewCategories.ValidationRule = new RegexValidationRule("^\\d+$"); ConditionCategoryControlViewModel dataContext = (ConditionCategoryControlViewModel)DataContext; MessageView.AssignYesNoMessage(dataContext.MessageBox); } _isNewInstance = false; }