Click here to Skip to main content
15,915,319 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: I marked My property with [DataMember] and I still have an exception Pin
Doria22863-Jun-09 0:05
Doria22863-Jun-09 0:05 
GeneralRe: I marked My property with [DataMember] and I still have an exception Pin
Pete O'Hanlon3-Jun-09 0:14
mvePete O'Hanlon3-Jun-09 0:14 
GeneralRe: I marked My property with [DataMember] and I still have an exception Pin
Doria22863-Jun-09 0:19
Doria22863-Jun-09 0:19 
GeneralRe: I marked My property with [DataMember] and I still have an exception Pin
Pete O'Hanlon3-Jun-09 0:30
mvePete O'Hanlon3-Jun-09 0:30 
QuestionWCF DataContract Structs Pin
Jammer2-Jun-09 1:17
Jammer2-Jun-09 1:17 
AnswerRe: WCF DataContract Structs Pin
Pete O'Hanlon2-Jun-09 1:34
mvePete O'Hanlon2-Jun-09 1:34 
GeneralRe: WCF DataContract Structs Pin
Jammer2-Jun-09 8:10
Jammer2-Jun-09 8:10 
QuestionDatabinding? Pin
#realJSOP1-Jun-09 23:51
professional#realJSOP1-Jun-09 23:51 
I have a form that has several labels that are updated on a regular basis. I was under the assumption that if I set up a proper class (inheriting from INotifyPropertyChanged), events would be sent to the form whenever a property changed. So, I wrote this (abbreviated to avoid boring you):

public class FormProperties : INotifyPropertyChanged
{
    private string m_scrambledWord;
 
    public string ScrambledWord
    {
        get { return m_scrambledWord; }
        set 
        {
            m_scrambledWord = value;
            OnPropertyChanged("ScrambledWord");
        }
    }

    public FormProperties()
    {
        m_scrambledWord = "test";
    }

    public event PropertyChangedEventHandler PropertyChanged;                
    protected void OnPropertyChanged(string propertyName)                    
    {                                                                        
        if (this.PropertyChanged != null)                                    
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }                                                                       
}


And in the form, I'm doing this:

FormProperties m_formProperties = new FormProperties();


Finally, I'm doing this in the XAML:

<Window x:Class="AnagramsWPF.WindowMain"
		x:Name="MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:AnagramsWPF"
		Title="Anagrams/WPF" 
		Height="566" Width="487" 
		FontFamily="Arial" FontSize="13"
		DataContext="m_formProperties">  <----------------

    <Grid>
        <TextBox Name="textboxScrambled" 
				 Height="23" 
				 Width="126" 
				 HorizontalAlignment="Left" 
				 VerticalAlignment="Top" 
				 Margin="111,6,0,0" 
				 IsReadOnly="True" 
				 MaxLines="1" 
				 MaxLength="10" 
				 CharacterCasing="Upper" 
				 Text="{Binding Path=ScrambledWord, Mode=OneWay}" />
    </Grid>
</Window>


I was expecting the form to be initialized with the associated textbox being set to "test". What am I doing wrong?

BTW, this databinding stuff seems like it's the long way around to setting the controls on a form.


"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


AnswerRe: Databinding? Pin
Pete O'Hanlon2-Jun-09 0:04
mvePete O'Hanlon2-Jun-09 0:04 
GeneralRe: Databinding? Pin
#realJSOP2-Jun-09 0:08
professional#realJSOP2-Jun-09 0:08 
GeneralRe: Databinding? Pin
ABitSmart2-Jun-09 0:39
ABitSmart2-Jun-09 0:39 
GeneralRe: Databinding? Pin
Pete O'Hanlon2-Jun-09 0:40
mvePete O'Hanlon2-Jun-09 0:40 
GeneralRe: Databinding? Pin
#realJSOP2-Jun-09 2:25
professional#realJSOP2-Jun-09 2:25 
GeneralRe: Databinding? Pin
Pete O'Hanlon2-Jun-09 2:32
mvePete O'Hanlon2-Jun-09 2:32 
GeneralRe: Databinding? Pin
#realJSOP2-Jun-09 3:11
professional#realJSOP2-Jun-09 3:11 
GeneralRe: Databinding? Pin
Pete O'Hanlon2-Jun-09 3:16
mvePete O'Hanlon2-Jun-09 3:16 
GeneralRe: Databinding? Pin
#realJSOP2-Jun-09 3:28
professional#realJSOP2-Jun-09 3:28 
QuestionList Control in WPF Pin
krishnan.s1-Jun-09 21:45
krishnan.s1-Jun-09 21:45 
AnswerRe: List Control in WPF Pin
Pete O'Hanlon1-Jun-09 23:10
mvePete O'Hanlon1-Jun-09 23:10 
QuestionWord wrap in RichTextBox Pin
hain1-Jun-09 10:25
hain1-Jun-09 10:25 
Questionhow to close a window.. Pin
Hema Bairavan1-Jun-09 0:18
Hema Bairavan1-Jun-09 0:18 
AnswerRe: how to close a window.. Pin
ABitSmart1-Jun-09 6:00
ABitSmart1-Jun-09 6:00 
QuestionVisualChildrenCount.. Pin
Hema Bairavan1-Jun-09 0:10
Hema Bairavan1-Jun-09 0:10 
AnswerRe: VisualChildrenCount.. Pin
Pete O'Hanlon1-Jun-09 1:28
mvePete O'Hanlon1-Jun-09 1:28 
GeneralRe: VisualChildrenCount.. Pin
Hema Bairavan1-Jun-09 1:33
Hema Bairavan1-Jun-09 1:33 

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.