Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Required field Validation in WPF

Required field Validation in WPF

Scheduled Pinned Locked Moved WPF
wpfcsharphelpasp-netwcf
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 8435384
    wrote on last edited by
    #1

    Dear All, I am in need of Validation of my textboxes when i click save button in WPF. I have tried this code : app.xaml ------------- <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value=""> <!--Set the TextBox Border--> <Setter Property="TextBox.BorderBrush" Value="{StaticResource MySolidBrush}" /> <!--Set the Inner TextBox BG--> <Setter Property="TextBox.Background" Value="{StaticResource MyInnerBrush}"/> <!--Set the RFV Tooltip--> <Setter Property="TextBox.ToolTip" Value="This Field is Mandatory"/> </DataTrigger> </Style.Triggers> test.xaml -------------- sumbit</Button> The code is showing the message as tool tip when i move the cursor to textbox. Since I am new to WPF, i need a code for Requiredfield validator as same as ASP.Net. I have refered the Binding Rules (Validation Rules) concept also , but not know how to do. All my need is when I click my button , It should show the error message to type something. Please help me on this,Its urgent. :sigh: Regards, SelvaKathir.C

    U 1 Reply Last reply
    0
    • U User 8435384

      Dear All, I am in need of Validation of my textboxes when i click save button in WPF. I have tried this code : app.xaml ------------- <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value=""> <!--Set the TextBox Border--> <Setter Property="TextBox.BorderBrush" Value="{StaticResource MySolidBrush}" /> <!--Set the Inner TextBox BG--> <Setter Property="TextBox.Background" Value="{StaticResource MyInnerBrush}"/> <!--Set the RFV Tooltip--> <Setter Property="TextBox.ToolTip" Value="This Field is Mandatory"/> </DataTrigger> </Style.Triggers> test.xaml -------------- sumbit</Button> The code is showing the message as tool tip when i move the cursor to textbox. Since I am new to WPF, i need a code for Requiredfield validator as same as ASP.Net. I have refered the Binding Rules (Validation Rules) concept also , but not know how to do. All my need is when I click my button , It should show the error message to type something. Please help me on this,Its urgent. :sigh: Regards, SelvaKathir.C

      U Offline
      U Offline
      Unnikrishnan_S_N
      wrote on last edited by
      #2

      Hi SelvaKathir, I assume you have implemented the following things for triggering the Error. 1. Viewmodel implements IDataErrorInfo interface. 2. Set ValidationAttribute on each property which has to be validated or Use SelfValidation attribute on the class and override DoValidate. 3. Controls in Xaml are using bindings and ValidatesOnDataErrors=true,NotifyOnValidationError=true 4. Use a textblock to display the error by binding the error content of the target field. "

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups