Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binding IsEnabled to count of selected items
Message
De
06/01/2014 14:43:01
 
 
À
06/01/2014 12:56:54
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01591392
Message ID:
01591414
Vues:
37
>>Hi,
>>
>>I have a delete button on a WPF form which I only want enabled whenever one and only one item is selected in a grid on the same form. I figure I have to do something like this:
>>
>>IsEnabled="{Binding ElementName=grdManifest, Path=Items.Selected.Count = 1}"
>>
>>but that isn't accepted as valid code.
>>
>>Any ideas on how to do this?
>
>Implement an IValueConverter (http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter%28v=vs.110%29.aspx) to convert your int value (the count) to a bool. Since its a one way binding, you don't need to implement ConvertBack, just throw a NotImplementedException.

Hi,
I wondered about using that approach but it's a pretty specific need and I'm fairly sure you'd still need to implement INotifyPropertyChanged so I opted for my suggestion. Can you provide a working example using valueconverter ?
Best,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform