Click here to Skip to main content
15,916,189 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:24
Ian Shlasko24-Jul-09 10:24 
GeneralMessage Removed Pin
24-Jul-09 10:36
professionalN_tro_P24-Jul-09 10:36 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:42
Ian Shlasko24-Jul-09 10:42 
GeneralMessage Removed Pin
24-Jul-09 10:46
professionalN_tro_P24-Jul-09 10:46 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:51
Ian Shlasko24-Jul-09 10:51 
GeneralMessage Removed Pin
24-Jul-09 10:19
professionalN_tro_P24-Jul-09 10:19 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:28
Ian Shlasko24-Jul-09 10:28 
AnswerRe: Binding IsEnabled of a button Pin
Pete O'Hanlon24-Jul-09 11:07
mvePete O'Hanlon24-Jul-09 11:07 
Rather than do this - use a notification property, as in:
public class NewSet : INotifyPropertyChanged
{
  private bool _isValid;
  public bool IsValidNewSet
  {
    get { return _isValid; }
    set
    {
      if (_isValid != value)
      {
        _isValid = value;
        OnChanged("IsValidNewSet");
      }
    }
  }

  protected virtual void OnChanged(string propertyName)
  {
    PropertyChangedEventHandler handler = propertyChanged;
    if (handler != null)
    {
      handler(this, new PropertyChangedEventArgs(propertyName);
    }
  }
  public event PropertyChangedEventHandler PropertyChanged
  {
    add { propertyChanged += value; }
    remove { propertyChanged -= value; }
  }
  private event PropertyChangedEventHandler propertyChanged;
}
Then, set this up as your DataContext, e.g. in Window1 (probably just after you call InitializeComponent()), set your DataContext to an instance of this class.

Finally, in your XAML, all you need do is bind to this item using:
<Button IsEnabled="{Binding IsValidNewSet}" />


"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



QuestionMessage Removed Pin
24-Jul-09 3:58
professionalN_tro_P24-Jul-09 3:58 
Questionsilverlight 3 Pin
wolfbinary24-Jul-09 3:36
wolfbinary24-Jul-09 3:36 
AnswerRe: silverlight 3 Pin
Pete O'Hanlon24-Jul-09 4:34
mvePete O'Hanlon24-Jul-09 4:34 
GeneralRe: silverlight 3 Pin
wolfbinary24-Jul-09 6:22
wolfbinary24-Jul-09 6:22 
GeneralRe: silverlight 3 Pin
Mark Salsbery24-Jul-09 11:08
Mark Salsbery24-Jul-09 11:08 
QuestionHosting MS Office in WPF app Pin
amit_198624-Jul-09 1:41
amit_198624-Jul-09 1:41 
AnswerRe: Hosting MS Office in WPF app Pin
Pete O'Hanlon24-Jul-09 2:18
mvePete O'Hanlon24-Jul-09 2:18 
QuestionUsing directional keys to rotate a 3D model? Pin
Etienne_12323-Jul-09 7:02
Etienne_12323-Jul-09 7:02 
AnswerRe: Using directional keys to rotate a 3D model? Pin
Pete O'Hanlon24-Jul-09 0:46
mvePete O'Hanlon24-Jul-09 0:46 
Questionconversion of Web rendering units to Wpf rendering units Pin
vsaratkar23-Jul-09 7:00
vsaratkar23-Jul-09 7:00 
QuestionMessage Removed Pin
23-Jul-09 5:45
professionalN_tro_P23-Jul-09 5:45 
AnswerRe: Templates and Libraries Pin
Mark Salsbery23-Jul-09 6:36
Mark Salsbery23-Jul-09 6:36 
QuestionSystem.Security. Security Exception in Silver light Pin
Nekkantidivya23-Jul-09 2:49
Nekkantidivya23-Jul-09 2:49 
AnswerRe: System.Security. Security Exception in Silver light Pin
Michael Sync23-Jul-09 6:00
Michael Sync23-Jul-09 6:00 
QuestionHow to create channel factory for Sync Wcf contract? Pin
pioner22-Jul-09 23:48
pioner22-Jul-09 23:48 
AnswerRe: How to create channel factory for Sync Wcf contract? Pin
Michael Sync23-Jul-09 6:05
Michael Sync23-Jul-09 6:05 
AnswerRe: How to create channel factory for Sync Wcf contract? Pin
Mark Salsbery23-Jul-09 6:21
Mark Salsbery23-Jul-09 6:21 

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.