Shortcut only in some cases

hi! I have 2 buttons (btnDelete and btnClear), which are activated when an item of a listview is selected. Each button has a quick access.
<Window.InputBindings>
<KeyBinding Command="{Binding DeleteCommand}" Modifiers="Control" Key="D"/>
<KeyBinding Command="{Binding ClearCommand}" Modifiers="Control" Key="C"/>
</Window.InputBindings>
What I need is that the command is activated only when the button is active and not always. You may do this with xalm? THX!

Ok, it looks like this is a bug in MvvmLight:
https://mvvmlight.codeplex.com/workitem/7659
Change the namespace of the RelayCommand class from GalaSoft.MvvmLight.Command to GalaSoft.MvvmLight.CommandWpf and it should work as expected:
using GalaSoft.MvvmLight.CommandWpf;
You may also call the DeleteCommand.RaiseCanExecuteChanged() method whenever you want the CanExecute method of the command to be called again.
Here is a complete example that works as expected:
ViewModel.cs:
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using System.Collections.ObjectModel;
namespace WpfApplication20
public class Article
public class ViewModel : ViewModelBase
public ViewModel() {
this.Articles = new ObservableCollection<Article>();
this.Articles.Add(new Article());
this.Articles.Add(new Article());
this.Articles.Add(new Article());
public ObservableCollection<Article> Articles {
get;
set;
private Article _selectedArticle;
public Article SelectedArticle {
get {
return _selectedArticle;
set {
_selectedArticle = value;
RaisePropertyChanged();
DeleteCommand.RaiseCanExecuteChanged();
public RelayCommand DeleteCommand {
get {
return new RelayCommand(Delete, () =>
return this.SelectedArticle != null;
private void Delete() {
Articles.Remove(_selectedArticle);
MainWindow.xaml:
<Window x:Class="WpfApplication20.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<Button Grid.Row="0" Grid.Column="1" Name="btnDelete"
BorderThickness="2"
Command="{Binding DeleteCommand}"
ToolTip="Delete (Ctrl + D)"
Margin="5">
<!-- NOTE that IsEnabled is removed -->
<StackPanel Orientation="Horizontal">
<!--<Image Source="Imagenes/Botones/Borrar.png" Margin="5,5,0,5" Height="32"/>-->
<Image Source="av1.png" Margin="5,5,0,5" Height="32"/>
<TextBlock VerticalAlignment="Center" Margin="5" FontWeight="Bold" Text="Delete"/>
</StackPanel>
</Button>
<ListView Name="lvl"
Margin="5"
Height="200"
ItemsSource="{Binding Articles}"
SelectedItem="{Binding SelectedArticle}"/>
</StackPanel>
</Window>
MainWindow.xaml.cs:
using System.Windows;
namespace WpfApplication20
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public MainWindow() {
InitializeComponent();
this.DataContext = new ViewModel();
Once again, note that you must remove IsEnabled from the XAML markup.
Hope that helps.
Please rememeber to mark all helpful posts as answer and/or helpful.

Similar Messages

  • Why is Coral option given only in some cases.?

    how come i some times can only have coral as an option to open a raw or jpg with ?

    Noel,
    With the correction to Corel, I am with you - most likely a File Association issue. This could be especially true, if Corel (PhotoPaint, etc.) has been installed more recently, than Ps - some program automatically alter File Associations, upon installation, and the user has to go in, and clean that up.
    Once, Apple's QT Player would change almost EVERY File Association on a PC to use it - even for file formats, that QT Player could not handle, like .DOC, etc.. Fortunately, more and more programs allow the user to choose which formats will be associated with the program being installed, but some have not "grown up" yet.
    Hope that you are correct, as that will be an easy fix.
    Hunt

  • "D" (Develop Loupe View) shortcut ignored in some cases

    When in "Spot Removal", "Red Eye", "Graduated Filter" and "Adjustment Brush" modes, the "D" shortcut key is ignored.  This is strange as all the other shortcuts, such as G (Grid View), E (Library Loupe View), C (Compare View) work fine.

    You can press the active tool's shortcut to dismiss it. For example, hit K to activate the Adj. Brush and hit K again to dismiss.
    Hitting Enter also dismisses any active develop module tool.
    But D, never did what you're asking to.

  • In putting together a book I can move photos onto a page and enlarge the picture but is there a way to reduce the picture size? some cases I want a smaller picture and if I change the size of the picture box I only get a portion of the image. I wnt to red

    picture size...in putting together a book I can move photos onto a page and enlarge the picture but is there a way to reduce the picture size? some cases I want a smaller picture and if I change the size of the picture box I only get a portion of the image. I want to reduce the image to fit the size of the box.

    If you right click on the image on the page in the context menu select photo box alignment and then select one of scale to fit {centered, Left-aligned, Right-aligned}
    That should do what you are loking for.

  • Auto closing of dispute cases--only for some company codes

    Hi
    We have activated dispute management for several company codes in our system. The auto closing of dispute cases also has been activated in status management. Cases are automatically closed by the system (through a batch job) when the last disputed object is cleared.
    Now there is a requirement to deactivate auto closing only for some company codes. They want to close cases manually in these company codes.
    Is this possible and if so how?
    Regards
    Raj.

    You cannot deselect at a company code level.
    Can we go through you proposed process.
    So you have a dispute for $100.
    The customer pays it and the dispute closes.
    Then the customer calls up and says they have an issue with the invoice they paid previously.
    I have seen this happen before but there was a little twist
    1 - The customer raised a debit note against the client for the issue that they had. The original invoice is cleared but a debit note is created and then disputed and processed. So you can close the original dispute and create a new dispute against the debit note
    2 - The customer paid the wrong invoice. The dispute was closed. However to rectify the miss allocation the clearing document will be reversed meaning the dispute is "re-opened" and can be processed.
    I am unaware of any other requirement for a customer to "re-dispute" a paid item in SAP.

  • I update my photoshop touch to 1.6 and the native font is not scaling correctly, whenever i enter for example "hello" i only get "he" and in some cases just pieces of words after resizing it, help!!!

    I update my photoshop touch to 1.6 and the text is not working, whenever i enter for example "hello" i only get "he" and in some cases just pieces of words, help!!!
    Message was edited by: Ignacio Barrientos
    Message was edited by: Ignacio Barrientos

    Thanks Laparra!! Thanks to your original comment again-- at least now I know if I need a "work-around" I now know at-least-that-the original-fonts in PS TOUCH seem to work. No wonder the default-font worked.. but not the NEW COPPERPLATE FONT.. YaY, mystery solved.. (almost)!   [i wished they'd change that default-font..and get a new default font...Lol.. It's pretty homely looking..Hee.) I normally have been using that original TRAJAN PRO FONT.. but the letter "J" almost looks like a straight line vs a rounded J.. which at least the new COPPERPLATE FONT (which is a more normal usable font--That's not boring like aerial is,etc... ]. So yeah that will be great when all those new fonts gets fixed! // It would be great too (on my PS TOUCH wishlist, if someday they could fix the TEXT BOX too.. to be able to better & easily add A LOT [more] TEXT on a graphic .. as I always have to go to the "OVER APP" [That's the name of the app in the APPLE store] on my iPad to do that... PS TOUCH only seems to let you do TITLES vs a more lengthy text on a project. If I want to make an EASY border I take the image I've been working on into the CAMERA+.Plus App.. Simple..[but I know it can lose its resolution]. Sorry so long!! Venting haha!! Will plan to keep an eye on this post & let you all know & visa versa! LORD BLESS!!

  • HT4539 My downloads are incomplete, in some cases only 30 seconds per episode.  completely shut down computer and programs.  Is there a real human to talk to?? Tech person nice but referrals to links too complicated. THX

    Easy way to fix this download problem.  Tech person nice but referrals to links WAY too complicated.  I just want to easily load program I paid for.
    My downloads are incomplete, in some cases only 30 seconds per episode.  completely shut down computer and programs to try to remedy. 
    Is there a real human to talk to at Itunes who won't say your warrenty is over so I can't help you?? THX

    Easy way to fix this download problem.  Tech person nice but referrals to links WAY too complicated.  I just want to easily load program I paid for.
    My downloads are incomplete, in some cases only 30 seconds per episode.  completely shut down computer and programs to try to remedy. 
    Is there a real human to talk to at Itunes who won't say your warrenty is over so I can't help you?? THX

  • How to use only one event case at a time??

    Using LabVIEW, using the event structure is it possible to have only one event case execute at a time. For example, having event case controlled by keyboard, and the other event case controlled by mouse (clicking buttons) and only one being able to execute, not simultaneously. I was considering using a switch of some sort, but each case does not have a "stop if true/false" so I am open to a new method or work around. I attached code. I do not want output to be able to be sent from the keyboard case and mouse case at the same time.
    Thanks,
    Andrew
    Attachments:
    WiFi Motor Control & Cam Stripped.vi ‏29 KB

    Ah, OK. all you need is to keep state in a shift register that ensures that all "key down/mouse down" events are discarded after each key down/mounse down event until a key up or mouse up (resp.) has occured.
    Overall, you code is still way to complicated for this simple task. For example, you could eliminate all these "select" primitives and place the approriate diagram constant inside the respective case. On the other hand it is too simplistic, because you would think that certain key combinations should be allowed concurrently (e.g. up and left).
    What does the receiver actually do with the codes? Do you have any documentation for this device?
    LabVIEW Champion . Do more with less code and in less time .

  • Page back wont work. The page reference is lost in some cases regardless of web site (intermittent)

    page back won't work The page reference is lost in some cases regardless of web site or action taken(the problem is intermittent)
    I have three home tabs and on some occasions if I open one of them and start to browse it I can't return to the top page. It doesn't always happen and it can happen on any of them. It made using apps impossible and the only way to correct the situation is to hit the home key and close the incorrect tabs

    It's also possible your session history file is not updating correctly, because you should not be thrown back to an earlier state in a tab.
    By default, Firefox updates the sessionstore.js file every 15 seconds with any changes. But occasionally Firefox may stop updating the file or may find that the file is locked and start creating a different sessionstore file (which is never restored and just sites orphaned in your profile folder).
    Could you take a look?
    Open your current Firefox settings (AKA Firefox profile) folder using either
    * "3-bar" menu button > "?" button > Troubleshooting Information
    * (menu bar) Help > Troubleshooting Information
    In the first table on the page, click the "Show Folder" button.
    In the window that launches, switch the view to Details and scroll down to the sessionstore files. You may find:
    * sessionstore.js (current session)
    * sessionstore.bak (previous session windows and tabs)
    * sessionstore.bak-''datetime'' (windows and tabs at your last update)
    * sessionstore-1.js (or other numbered files -- session history that couldn't be saved into sessionstore.js)
    Note: If Windows does not display .js extension, please switch off the hiding of file extension using the procedure in this article: [http://windows.microsoft.com/en-us/windows/show-hide-file-name-extensions http://windows.microsoft.com/en-us/windows/show-hide-file-name-extensions].
    Anything odd about the timestamps or any numbered sessionstore files?

  • Outlook asking for username and password, but only for some users

    Hello, I'm
    in an Exchange Server 2013 client
    environment, two CAS servers
    and two Mailbox.
    Some users are having trouble in Outlook 2007
    and 2012, which is directly
    requesting the user name and password, not all,
    just some.
    The Active Directory is ok,
    DNS and also own Exchange
    servers apparently do not see errors.
    Has anyone here ever experienced this?
    How can I solve this problem?
    As this happens only to some users
    and the vast majority have no problems, so
    difficult to find the cause.
    Thank you!
    Ivanildo Teixeira Galvão

    Hi Ivanildo,
    From your description, only some users have an issue that Outlook prompts for username and password. In your case, I recommend you compare the normal and problematic Outlook settings. Here is the Outlook settings in my environment for your reference:
    1. "Always prompt for logon credentials" isn't checked.
    2. Logon network security using Negotiate Authentication.
    3. "Connect to Microsoft Exchange using HTTP" is checked.
    4. Use the NTLM Authentication when connecting to my proxy server for Exchange.
    Hope this can be helpful to you.
    Best regards,
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Amy Wang
    TechNet Community Support

  • All I want is all my contacts on my phone and the same on my iMac, but no, that's too much to ask, instead I get everything doubled up on the phone and everything doubled up (triple in some cases) on the iMac, why does it do this? and more importantly how

    All I want is all my contacts on my phone and the same on my iMac, but no, that's too much to ask, instead I get everything doubled up on the phone and everything doubled up (triple in some cases) on the iMac, why does it do this? and more importantly how can I stop it? Thanks

    Look under system preferences on the mac at what is be controlled?  Look at Mail, Contacts, Calendars.  How many accounts are managing contacts?  Just the cloud? the cloud and gmail? or cloud, gmail, yahoo, and exchange?  If you have more than one contact account, then you will have different contact lists, if John Smith shows up in more than one of your contact lists, you will have multiple entries.
    Pick a contact list that is your master, (I use iCloud), only turn on contact syncing for it.  The same for your phone.  Spend some time on the iCloud webset (www.icloud.com) and work on your contact list there.  Clean it up, remove duplicates, etc...Changes will auto sync back to all your devices.  Life gets much simplier.
    Just remember, if you sync different contacts lists and a large number of people appear in your different lists, then they will appear as duplicates.

  • Can I create delivery in some case where backorder flag is set

    Hi,
    I have a typical scenario where I want to create delivery even backorder flag is set which will happen in some case only.
    Thanks in advance,
    Alok

    hai alok
    this can be done bu tit is fucntionla thing
    u cna post same in sd forum
    m.a

  • I have an email thread that has become unprintable (and in some cases unreadable) because each email in the thread is indented and eventually the text is very far to the right margin and even beyond.  How do I correct this?

    I have an extremely long and important email thread that has become unprintable (and in some cases unreadable) because each preceding email in the thread is indented and eventually the text is very far to the right margin and even beyond.  Some of the text is even showing up as only 1 letter per line.  I tried selecting all and then left justifying it, thinking that that would shift everything to the left, but it didn't work.   When I go to print the thread, it shows as 344 pages, which although long, I can't believe it's that long.  What do you think happened to cause this and can it be corrected?

    Ick. So it can't just work sensibly? Sensible would be either autosave overwrites previously autosaved versions or all autosaved versions would be deleted when the message is finally sent. Allowing previous message versions to accumulate endlessly might be beneficial to someone, but does not seem like sensible default behavior.

  • I can only see some of the info (e.g. the email Facebook gives you) for some friends in Contacts. I can see everything for others. Their b-days aren't listed in my Contacts (but these friends have their B-days on their profile on FB). Can anyone help?

    Hello,
    I can only see some of the information of my Facebook friends in my Contacts. For example, a friend has a birthday today. I received an email that she and another friend have birthdays this week. I received a notification on my iPhone and iPad that her birthday was today. It was never displayed in my Notification Center or Calendar beforhand, like it's displayed for other friend's (for other friends, it's displayed in the Notification Center, with the Calendar icon, 1 day before). I looked at every setting I could think of and the Help pages on Facebook. Nothing is working. My friend with the birthday today has her birthday openly listed on her Profile information on her Facebook page. In my contacts, her Facebook email (the one Facebook assigns you when you join) is listed. However her picture and birthday are not listed. I displayed my Facebook Contacts only, and roughly 20 showed up and not the rest. It's like the devices are not recognizing those people and putting their information in the respective places. I have an iPad 3rd Gen, iPhone 5, and MacBook Pro (purchased in January 2013. I hope that helps) and ALL the software updates are current. Can anyone help? Also, my MacBook cannot access my Contacts from Yahoo. Despite my typing in the correct password repeatedly as well as deleting and adding the Yahoo account again. I'd be grateful for any and all help. Thank you. 

    Step by step, how did you arrive at seeing this agreement?

  • How do I add a new user to my account? But I wanna give him a special product (e.g. InCopy) only for some month...

    I am admin and I want to add a new user to my account. But as written above, I want that he/she will get this product only for some month and not for a whole year.
    Thanks for the help.

    Team license links that may help
    -manage your team account http://forums.adobe.com/thread/1460939?tstart=0
    -Team Installer http://forums.adobe.com/thread/1363686?tstart=0

Maybe you are looking for

  • Fpga data persistence volatility

    I was just wondering about the persistence/volatility of the various memory methods after cycling power to LabVIEW FPGA Devices?  Is it possible to ensure that data persists after cycling power? Jordan McBain, PhD LabVIEW Controls Engineer Revolution

  • How do i get to Type within a document

    All i am aakinf is How do i get to type within a document   what button do i hit to do this

  • Can you open two seperate apps at once?

    Can you have two separate apps open at once?

  • Blue line on the screen of my new Iphone4, pls help!!!

    I bought one Iphone4 at London, yesterday I try to power on and find out that there is a blue line on the right of the screen. Please help me, I do not know how to post photos here. If you want to see the phenomenon, please send me email. Another que

  • Unable to access internet on all my mobile devices

    I recently installed Hub5 with Infinity. At first install, no problems, all devices connected to Wi-fi and online. Next day, all mobile devices are connecting to Hub5 but cannot get online.  Laptops ok and not affected and all wired devices ok.  Devi