Click here to Skip to main content
15,896,278 members
Home / Discussions / WPF
   

WPF

 
QuestionWPF Grid double clicked event Pin
sughasini18-Feb-10 23:08
sughasini18-Feb-10 23:08 
AnswerRe: WPF Grid double clicked event [add timmer] Pin
ProtoBytes19-Feb-10 4:30
ProtoBytes19-Feb-10 4:30 
QuestionHow to hide a control when its available space is too small Pin
daniel radford18-Feb-10 22:30
daniel radford18-Feb-10 22:30 
AnswerRe: How to hide a control when its available space is too small Pin
ProtoBytes19-Feb-10 4:31
ProtoBytes19-Feb-10 4:31 
QuestionSDK trouble in WPF Pin
Etienne_12318-Feb-10 6:07
Etienne_12318-Feb-10 6:07 
AnswerRe: SDK trouble in WPF Pin
Pete O'Hanlon18-Feb-10 9:51
mvePete O'Hanlon18-Feb-10 9:51 
GeneralRe: SDK trouble in WPF Pin
Etienne_12321-Feb-10 3:51
Etienne_12321-Feb-10 3:51 
QuestionText Box Validation in C#, not XAML? Pin
MattFunke18-Feb-10 4:49
MattFunke18-Feb-10 4:49 
My apologies for the relatively newbie-ish question -- I'm rather new to C# and WPF programming. Here's an object I'm trying to use with strong influence from Pro WPF in C# 2008 (.NET version 3.5) that's supposed to validate a text box's contents:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace LeanQualityTool
{
    public class ValidatedTextBox : TextBox, INotifyPropertyChanged, IDataErrorInfo
    {
        private string _TextContents = "";

        public string TextContents
        {
            get { return _TextContents; }
            set { _TextContents = value;
                  NotifyPropertyChanged("TextContents");
                }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #region IDataErrorInfo Members

        public string Error
        {
            get { return null; }
        }

        public string this[string fieldName]
        {
            get
            {
                string result = null;

                #region For Validating Text
                if (fieldName.Contains("Title"))
                {
                    if (this._TextContents.Length == 0)
                    {
                        result = "Text should not be blank";
                        throw new ArgumentException(result);
                    }
                    else
                    {
                        // Do searches for illegal chars in here if you like
                    }
                }
                #endregion

                return result;
            }

        #endregion
        }
    }
}



And here's the relevant XAML:

xmlns:vip="clr-namespace:LeanQualityTool"

                <vip:ValidatedTextBox Height="23" x:Name="txtJobTitle" HorizontalAlignment="Left" Width="276"
                     Style="{StaticResource validatedTextBox}">
                         <TextBox.Text>
                              <Binding Path="SelectedItem.Title" UpdateSourceTrigger="PropertyChanged"
                                       ValidatesOnDataErrors="True">
                              </Binding>
                         </TextBox.Text>
                </vip:ValidatedTextBox>



I try to put a breakpoint on the IF statement in the class, but when I debug the app, changing the text in the textbox doesn't even cause the breakpoint to engage. Why isn't the new ValidatedTextBox working?
AnswerRe: Text Box Validation in C#, not XAML? Pin
Stryder_118-Feb-10 6:17
Stryder_118-Feb-10 6:17 
GeneralRe: Text Box Validation in C#, not XAML? Pin
MattFunke18-Feb-10 7:07
MattFunke18-Feb-10 7:07 
AnswerRe: Text Box Validation in C#, not XAML? Pin
Pete O'Hanlon18-Feb-10 9:12
mvePete O'Hanlon18-Feb-10 9:12 
QuestionFacial recognition Pin
Etienne_12318-Feb-10 2:50
Etienne_12318-Feb-10 2:50 
AnswerRe: Facial recognition Pin
ProtoBytes19-Feb-10 4:36
ProtoBytes19-Feb-10 4:36 
AnswerRe: Facial recognition Pin
ProtoBytes19-Feb-10 4:46
ProtoBytes19-Feb-10 4:46 
QuestionDynamic loading Pin
nerra17-Feb-10 17:43
nerra17-Feb-10 17:43 
AnswerRe: Dynamic loading Pin
AspDotNetDev17-Feb-10 18:36
protectorAspDotNetDev17-Feb-10 18:36 
GeneralRe: Dynamic loading Pin
nerra17-Feb-10 20:59
nerra17-Feb-10 20:59 
Questionuse flash in asp.net Pin
zahramoghadam16-Feb-10 21:35
zahramoghadam16-Feb-10 21:35 
AnswerRe: use flash in asp.net Pin
Pete O'Hanlon16-Feb-10 22:52
mvePete O'Hanlon16-Feb-10 22:52 
AnswerRe: use flash in asp.net Pin
Abhinav S17-Feb-10 0:07
Abhinav S17-Feb-10 0:07 
QuestionPass parameters Pin
mehrdadov16-Feb-10 19:30
mehrdadov16-Feb-10 19:30 
AnswerRe: Pass parameters Pin
Pete O'Hanlon16-Feb-10 22:28
mvePete O'Hanlon16-Feb-10 22:28 
GeneralRe: Pass parameters Pin
mehrdadov17-Feb-10 4:31
mehrdadov17-Feb-10 4:31 
GeneralRe: Pass parameters Pin
Kevin McFarlane18-Feb-10 9:09
Kevin McFarlane18-Feb-10 9:09 
QuestionListBox, WrapPanel & Images Pin
Jammer16-Feb-10 10:19
Jammer16-Feb-10 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.