none
wpf PropertyChanged null RRS feed

  • 问题


  •    public class DownLondFileInformation : INotifyPropertyChanged
        {
            public event PropertyChangedEventHandler PropertyChanged;
            private int progPercent;
            int max;

            public int Max
            {
                get { return max; }
                set { max = value; OnPropertyChanged("Max"); }
            }
            public int ProgPercent
            {
                get { return progPercent; }
                set { progPercent = value; OnPropertyChanged("ProgPercent"); }
            }
            string title;

            public string Title
            {
                get { return title; }
                set { title = value; OnPropertyChanged("Title"); }
            }
            protected void OnPropertyChanged(string progPercent)
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(progPercent));

                }
               // this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(progPercent)); 
            }
                 
        }

     

     

     <ProgressBar Height="30" Name="progressbar"  Margin="0" Value="{Binding Path=ProgPercent ,Mode=TwoWay}"  Maximum="{Binding Path=Max ,Mode=TwoWay}" Width="250" HorizontalAlignment="Left" VerticalAlignment="Top"></ProgressBar>
                <TextBlock Text="{Binding Path=Title ,Mode=TwoWay}" Name="TextBlockTitle" Width="250" HorizontalAlignment="Left"></TextBlock>

     

     

    DownLondFileInformation DLFInformation=new DownLondFileInformation();

     this.progressbar.DataContext = DLFInformation;
                TextBlockTitle.DataContext = DLFInformation;

    2011年6月7日 5:33

答案