Click here to Skip to main content
15,913,467 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Converting WPF windows application to Web Application. Pin
Hema Bairavan22-Jan-13 0:24
Hema Bairavan22-Jan-13 0:24 
AnswerRe: Converting WPF windows application to Web Application. Pin
db7uk26-Jan-13 13:17
db7uk26-Jan-13 13:17 
QuestionGetting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Geert De Vylder21-Jan-13 4:51
Geert De Vylder21-Jan-13 4:51 
AnswerRe: Getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Mycroft Holmes21-Jan-13 18:36
professionalMycroft Holmes21-Jan-13 18:36 
GeneralRe: Getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Geert De Vylder21-Jan-13 20:55
Geert De Vylder21-Jan-13 20:55 
QuestionBinding to attached property Pin
savbace20-Jan-13 21:22
savbace20-Jan-13 21:22 
QuestionRoot element is not valid for navigation Pin
Vimalsoft(Pty) Ltd19-Jan-13 19:18
professionalVimalsoft(Pty) Ltd19-Jan-13 19:18 
AnswerRe: Root element is not valid for navigation Pin
Richard Deeming21-Jan-13 1:55
mveRichard Deeming21-Jan-13 1:55 
GeneralRe: Root element is not valid for navigation Pin
Vimalsoft(Pty) Ltd21-Jan-13 4:49
professionalVimalsoft(Pty) Ltd21-Jan-13 4:49 
QuestionRandom Image with array Pin
Tikha17-Jan-13 11:23
Tikha17-Jan-13 11:23 
AnswerRe: Random Image with array Pin
Pete O'Hanlon17-Jan-13 21:21
mvePete O'Hanlon17-Jan-13 21:21 
AnswerRe: Random Image with array Pin
Abhinav S19-Jan-13 2:24
Abhinav S19-Jan-13 2:24 
GeneralRe: Random Image with array Pin
Tikha21-Jan-13 17:09
Tikha21-Jan-13 17:09 
GeneralRe: Random Image with array Pin
Dave Kreskowiak21-Jan-13 17:54
mveDave Kreskowiak21-Jan-13 17:54 
QuestionDispatcherTimer Tick event not fired Pin
Praveen Raghuvanshi17-Jan-13 4:54
professionalPraveen Raghuvanshi17-Jan-13 4:54 
AnswerRe: DispatcherTimer Tick event not fired Pin
Paulo Zemek23-Jan-13 6:28
Paulo Zemek23-Jan-13 6:28 
QuestionWhich way to load entity child collections? Pin
Adam_Dev16-Jan-13 5:11
Adam_Dev16-Jan-13 5:11 
QuestionWPF with Web Pin
Rishabh Kumar14-Jan-13 8:42
Rishabh Kumar14-Jan-13 8:42 
AnswerRe: WPF with Web Pin
Abhishek Pant14-Jan-13 9:17
professionalAbhishek Pant14-Jan-13 9:17 
AnswerRe: WPF with Web Pin
Abhinav S16-Jan-13 17:20
Abhinav S16-Jan-13 17:20 
QuestionWPF - Bind IsEnabled To Method On VM Pin
Kevin Marois13-Jan-13 11:06
professionalKevin Marois13-Jan-13 11:06 
AnswerRe: WPF - Bind IsEnabled To Method On VM Pin
Wayne Gaylard14-Jan-13 0:55
professionalWayne Gaylard14-Jan-13 0:55 
AnswerRe: WPF - Bind IsEnabled To Method On VM Pin
Richard Deeming14-Jan-13 2:13
mveRichard Deeming14-Jan-13 2:13 
If you're using .NET 4.0 or 4.5, you can combine a single property with a dynamic object to achieve this:
C#
public interface ICanEnableField
{
   bool CanEnableField(string key);
}

public sealed class CanEnableFieldHelper : DynamicObject
{
   private readonly ICanEnableField _owner;
   
   public CanEnableFieldHelper(ICanEnableField owner)
   {
      _owner = owner;
   }
   
   public override bool TryGetMember(GetMemberBinder binder, out object result)
   {
      result = _owner.CanEnableField(binder.Name);
      return true;
   }
}

public class YourViewModel : ICanEnableField
{
   private readonly CanEnableFieldHelper _helper;
   
   public YourViewModel()
   {
      _helper = new CanEnableFieldHelper(this);
   }
   
   public dynamic CanEnable
   {
      get { return _helper; }
   }
   
   public bool CanEnableField(string key)
   {
      ...
   }
}

In you XAML, you can then bind to CanEnable.Key, which will return the result of calling CanEnableField("Key"):
XML
<TextBox IsEnabled="{Binding Path=CanEnable.Field1}" ... />

When you need to change the state, you just need to raise the PropertyChanged event for the CanEnable property.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: WPF - Bind IsEnabled To Method On VM Pin
Kevin Marois14-Jan-13 10:40
professionalKevin Marois14-Jan-13 10:40 
GeneralRe: WPF - Bind IsEnabled To Method On VM Pin
Kevin Marois20-Jan-13 8:47
professionalKevin Marois20-Jan-13 8:47 

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.