Hej..
Jeg vil lige have hjælp til noget validation...
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace Datavalidation
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- private string name;
-
- public string Name
- {
- get { return name; }
- set {
- if (String.IsNullOrEmpty(value))
- {
- throw new ApplicationException("Customer name is mandatory.");
- }
- name = value; }
- }
-
-
-
- public MainWindow()
- {
-
- InitializeComponent();
- }
-
-
- }
- }
<Window x:Class="Datavalidation.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox Margin="72,101,220,182">
<TextBox.Text>
<Binding Path="Name">
<Binding.ValidationRules>
<ExceptionValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</Grid>
</Window>
Jeg kan ikke får det her til at virke...?? Tekstbox må ikke være tom..
Indlæg senest redigeret d. 19.12.2011 19:02 af Bruger #16802