J'ai deux de ComboBox - être visible ailleurs son Collapsed cbo_client_pay_method & cbo_termsArrêt ValidationRule si ComboBox est Collapsed
L'un des éléments de cbo_client_pay_method (Le compte) exige cbo_terms (30 jours, etc ...), je présente fonctionnalité déjà configurée dans l'événement cbo_payment_type_SelectionChanged.
J'ai mis en place un ValidationRule qui testent si les années OBC ne sont pas nulles & & si selectedValue < 0 (quelque chose est sélectionné), cela fonctionne bien.
Tout cela fonctionne très bien, sauf si les cbo sont effondrés, la validation se déclenche toujours! Est-ce que je peux arrêter la validationRule si l'élément est réduit?
<StackPanel Name="sp_account" Orientation="Horizontal" VerticalAlignment="Center">
<Label Content="Payment" Style="{StaticResource formLabel}"/>
<Grid>
<ComboBox Name="cbo_client_pay_method" Style="{StaticResource reminder_cbo}" SelectionChanged="cbo_client_payMethod_SelectionChanged" Validation.ErrorTemplate="{StaticResource validationTemplate}">
<ComboBox.SelectedValue>
<Binding Path="client_payment_type_id" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True">
<Binding.ValidationRules>
<local:ValidCbo ErrorMessage="Select A Payment Type" />
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedValue>
</ComboBox>
<TextBlock Name="txtSelectPayMethod" Text="Please Select A Payment Method..." Style="{StaticResource cbo_overlay}" />
</Grid>
</StackPanel>
<StackPanel Name="sp_terms" Orientation="Horizontal" VerticalAlignment="Center">
<Label Content="Terms" Style="{StaticResource formLabel}"/>
<Grid>
<ComboBox Name="cbo_terms" Style="{StaticResource reminder_cbo}" SelectionChanged="cbo_terms_SelectionChanged" Validation.ErrorTemplate="{StaticResource validationTemplate}">
<ComboBox.SelectedValue>
<Binding Path="terms_id" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True">
<Binding.ValidationRules>
<local:ValidCbo ErrorMessage="Select Payment Terms" />
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedValue>
</ComboBox>
<TextBlock Name="txtSelectTerms" Text="Please Select Payment Terms..." Style="{StaticResource cbo_overlay}" />
</Grid>
</StackPanel>
public class ValidCbo : ValidationRule
{
private string _errorMessage;
public string ErrorMessage
{
get { return _errorMessage; }
set { _errorMessage = value; }
}
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
//if (this.ErrorMessage.Contains("Master") |)
if (value == null)
{
// value = null
return new ValidationResult(false, this.ErrorMessage);
}
else
{
// Not null
int selectedValue = (int)value;
if (selectedValue < 0)
{
return new ValidationResult(false, this.ErrorMessage);
}
else
{
return ValidationResult.ValidResult;
}
}
}
}
Merci H.B. C'est exactement ce que je cherchais :-) BTW je peux vous voir édité ma question et enlevé les onglets stupides, j'ai voulu faire cela mais je ne sais pas comment, des pointeurs ?? merci –
VisualStudio: Ctrl + E, D -> Autoformat | Alt + Clic + Glisser Souris -> Sélection de bloc de code Chose –
J'essayais de le faire sur StackOverflow! Salutations pour l'aide –