Set button state base on the state of items in list

Hi everyone,
I'm making an application that helps user to manages their file.
In my application, I have a list of files and a button Delete all.
I want the Delete all button to be disabled when all files in my list are hidden.
Can anyone help me please ?
Thank you :)

>>I want the Delete all button to be disabled when all files in my list are hidden.
Add a Hidden property to the class that represents a File in your application:
public class File : ViewModelBase
private bool _hidden;
public bool Hidden
get { return _hidden; }
set { _hidden = value; base.RaisePropertyChanged("Hidden"); }
...and bind the Command property of the Button to a RelayCommand (DeleteCommand) and make its CanExecute method return true only when there are at least one File object with the Hidden property set to false:
public class ViewModel
public ObservableCollection<File> Files { get; set; }
public RelayCommand DeleteCommand
get { return new RelayCommand(OnDelete, CanDelete); }
private bool CanDelete()
return Files.Any(f => !f.Hidden);
private void OnDelete()
//delete....
>>I wonder if the button state can be changed when an item state changes or not :)
Call the RaiseCanExecuteChanged() method of the DeleteCommand whenever the Hidden property of any File object in the Files collection is set to a new value.
You could do this by hooking up an event handler for the PropertyChanged event of each File object in the view model class like this:
public class ViewModel
public ViewModel()
this.Files = new ObservableCollection<File>();
//load files....
foreach (File file in this.Files)
(file as INotifyPropertyChanged).PropertyChanged
+= new PropertyChangedEventHandler(item_PropertyChanged);
this.Files.CollectionChanged += Files_CollectionChanged;
private void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
if(e.PropertyName == "Hidden")
DeleteCommand.RaiseCanExecuteChanged();
private void Files_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
if (e.NewItems != null)
foreach (object file in e.NewItems)
(file as INotifyPropertyChanged).PropertyChanged
+= new PropertyChangedEventHandler(item_PropertyChanged);
if (e.OldItems != null)
foreach (object file in e.OldItems)
(file as INotifyPropertyChanged).PropertyChanged
-= new PropertyChangedEventHandler(item_PropertyChanged);
public ObservableCollection<File> Files { get; set; }
public RelayCommand DeleteCommand
get { return new RelayCommand(OnDelete, CanDelete); }
private bool CanDelete()
return Files.Any(f => !f.Hidden);
private void OnDelete()
//delete....
Note that this requires the File class to implement the INotifyPropertyChanged.
Hope that helps.
Please mark helpful posts as answer to close the thread and then start a new thread if you have a new question.

Similar Messages

  • Is there a difference between Statement Cache and the statement handle!

    Hello!
    The OCI statement cache is !session! wide. When I have a sql statement that was used before, I can use this feature.
    But what is the difference between this feature and my statement handle for a certain sql statement that I can store and reuse a second time?
    My stored statement handle is already prepared and the placeholders are bound. The second time I only have to copy new values in the memory positions and do an execute and that's all.
    Thank you in advance
    Wolfgang

    The underlying optimization is the same. When you re-execute a statement, you are reusing the metadata already available in the statement and the cursor already open on the server. If you know exactly the set of statements that you are going to execute repeatedly, you can maintain the cache on your own. (Yes, you save on doing the Bind/Define calls multiple times).
    OCI Statement cache makes it transparent and the application does not need to keep the references/indexes to the relevant statements. Also once a cache size is set, least recently used statements get out of the cache when the cache is full and needs to accommodate more.
    To optimize the bind/defines on the statements from the statement cache, you can use this feature:
    http://www.filibeto.org/sun/lib/nonsun/oracle/11.2.0.1.0/E11882_01/appdev.112/e10646/oci09adv.htm#sthref1358

  • Sql statement to get the count of items in a group.

    i have a table  as follows
    group id   items
       1            item1
       1            item2
       1            item3
       2            item4
       2            item5
    i need to get the count of items for each group
    the out put should be like
    group = 1 count = 3
    group = 2 count = 2
    i wrote the following query
    select   group count( * )
       into     (group , lv_count)
      from     table1
      group by group.
      endselect.
    is it possible to write this query without using end select.
    when i am using the same query with into table addition the count is not coming.

    Hi,
    It will work, I tested just now, ofcourse with some other table.
    Like this:
    select group count( * )
    INTO TABLE ITAB
    from table1
    group by group.
    Regards,
    Amit Mittal.

  • Even though my email accounts seem to be set up when i press the email icon it just lists icloud, EOL etc and asks for new account to be set up

    Even though my email accounts seem to be set up when i press the email icon it comes up with Icloud, EOL etc like it is not set up.  When you press on icloud and put in details it says the account is already set up.
    Email had been set up and receiving and sending email but seems that no longer working.  Have i bumped something and how do i fix it.

    This is for Ipad rather iphone that am having this problem

  • How do I import a Photoshop button (including it's different states) into the muse menu widget?

    I had the idea of using the "place Photoshop button" option to configure the states in my horizontal menu bar in Muse.  I started out trying to use the widget, after playing with the options it seems I can either load each individual state one at a time in manual mode or I can try to make a menu bar from the buttons and manually place the respective links.  I would be grateful for a suggestion or alternative method that is as easy as the "place Photoshop button" option, I love that feature.  Thanks in advance.
    J
    UPDATE:  I found that I could use Fill image then in import fill options, import layer + clip layer contents for each of the states.  It was working very well but I noticed an error in one of my buttons states so I had to go back to Photoshop.  When I returned to start this process again and I clicked import layer, the states are all flat plain text without any of the blending options I had set for each state. The odd part is that I can see all the layers in composite, but it will not let me place each layer as it did before. 
    After several frustrating hours going through every step I edited and even trying to load the buttons I thought were exactly the same file I used before I could not find what I had done differently to cause this.  I did successfully place each Photoshop button in empty space and the cut and paste them into the menu. Which is way easier then the original method.  I would like to know if anyone has an idea what went wrong for the sake of knowledge.  Also thought that this cut paste method might help others trying to build menu buttons outside of Muse.    

    I'm afraid Photoshop is a graphics program ill suited for generating good HTML and CSS code.  Use Photoshop to create your images only. Use DW to build your HTML, CSS and menus.
    Have a look at this tutorial:
    Taking  a Fireworks (or Photoshop) comp to a CSS based layout in DW
    Part 1 --
    http://www.adobe.com/devnet/fireworks/articles/web_standards_layouts_pt1.html
    Part 2 --
    http://www.adobe.com/devnet/fireworks/articles/web_standards_layouts_pt2.html
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • The State System message file processing could not process

    Hi
    We have Windows server 2008R2 SCCM 2012 R2 CU3 SQL 2008 R2.
    Every 15-19 minutes I got two errors in State messages ID6104 (The State System message file processing could not process file 'HI6DYYB8.SMX' and moved it to the corrupt directory. Review the statesys.log file for further details.), 6105 (The State System
    message file processing processed one or more files that contained errors or invalid data. Review the statesys.log file for further details.). It started on Monday.
    Also on server  in statesys.log
    SQL MESSAGE: spProcessStateReport - Record 1 failed processing with error -50010:
    SMS_STATE_SYSTEM 26.02.2015 07:11:30
    9880 (0x2698)
    CMessageProcessor - Non-fatal error while processing HI6DYYB8.SMX
    SMS_STATE_SYSTEM 26.02.2015 07:11:30
    9880 (0x2698)
    STATMSG: ID=6104 SEV=E LEV=M SOURCE="SMS Server" COMP="SMS_STATE_SYSTEM" SYS=server.fqdn SITE=MYSITE PID=3744 TID=9880 GMTDATE=ce feb 26 05:11:30.119 2015 ISTR0="HI6DYYB8.SMX" ISTR1="" ISTR2="" ISTR3=""
    ISTR4="" ISTR5="" ISTR6="" ISTR7="" ISTR8="" ISTR9="" NUMATTRS=0
    SMS_STATE_SYSTEM 26.02.2015 07:11:30
    9880 (0x2698)
    Thread "State Message Processing Thread #0" id:9880 was unable to process file "D:\SCCM_prog\inboxes\auth\statesys.box\process\HI6DYYB8.SMX", moving to corrupt directory.
    SMS_STATE_SYSTEM 26.02.2015 07:11:30
    9880 (0x2698)
    total chucks loaded (0) SMS_STATE_SYSTEM
    26.02.2015 07:11:30 9880 (0x2698)
    What could cause this messages to appear?

    That just indicates that a state message sent by a client was somehow corrupted. You can examine the .smx that was moved to the corrupt-box, but it's not unusual that it happens. 
    Torsten Meringer | http://www.mssccmfaq.de

  • Simple State Machine Vs Queued State Machine

    Using LV2009 + WIN7+Pentium 4 @ 2.5Ghz with 3 GB RAM.
    I have a machine control code inside a 10mS main loop that has 7 ( yes seven ) Queued State Machines (  QSM) and I find the  Finished Late boolen keeeps poppping often. Not a very good sign if you ask me.
    And the code itself does not have too much of computation or FP activity. But it has four Graphs with one plot on each of them. These are updated once every 10ms. Can slowing this update ( say once every 250ms ? ) help ? 
    A simple query : In terms of performance overhead, does a QSM  demand more than a  Simple State Machine ( SSM ) ? Can I avoid the Finished Late warning by switching over to SSM at least in three of the cases out of the seven ?
    Thanks 
    Raghunathan
    LV2012 to Automate Hydraulic Test rigs.

    I think your question demonstrates my point.  Unfortunately, I don't have a good example to point you to and don't have the time to write one.  I will try to explain better.  Let's take a simple example - a landscape watering controller (sprinkler controller).  This controller will have several states (e.g. initializing, waiting, watering, closing). Each of these states will accept several commands, but not all commands are accepted in all states.  For example, if the system is watering, a command to start watering could be ignored.
    In most programs, at least some states should be interruptible.  For example, if it starts to rain, the watering system should stop watering immediately instead of watering for a set length of time.  However, if the system is in the initialization state, this will probably not be interruptible (but also short).
    As you said, the classic LabVIEW way to implement such a thing is to have a case statement to represent the state, and a case statement (usually queue driven) in each state frame to handle the commands.  You thus have a loop with a double case structure.  This can get somewhat unwieldy for large programs.  Note that which case structure represents what will be determined by the relative number of each item. For example, if you have fifty commands and three states, the state should go into the command case.
    So how do LabVIEW classes help?  They can eliminate one or both levels of these case structures through the use of dynamic dispatch.  This is done as follows.  A parent class is created that is a generic command.  It has commands for each state.  For each actual command, a class is derived from the parent class.  There are VIs in the specific command class for each state.  A command is generated by creating the correct object for the current state, then calling the parent class command.  Dynamic dispatch will execute the code for the correct command.  The command execution loop is then reduced to a single command VI which dynamically dispatches based on the actual command and the current state.
    In practice, things as usually not quite this simple, and you may want different cases for either different commands or different states so that you can change the connector pane of the dynamically dispatched VI as needed.  Look up the LabVIEW examples on dynamic dispatch to see this in action.
    I am afraid I have still not made myself clear.  Keep asking questions and I will try to keep answering.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Next Set / Prev Set buttons

    HI,
    I have a concert that I've set up in which each set has a patch with a Playback plugin that plays my backing trax. The next set button is configured at the concert level. but it doesn't work. I have my Playback plugin instituted at the Set level, so my footpedal on my line 6 Toneport will start/stop playback. If I put in even just an empty patch in a set, playback doesn't work, but then the next set/prev set buttons will. I've got about 50 songs in my Concert.
    Thanks,
    St Mix

    To the Oracle Reports Team,
    Could you or anyone else send me, a sample code of a jsp report that uses startRow and endRow attributes in rw:for each JSP tag. I couldn't find out how to include and use these attributes in the example mentioned in reports9i online help.
    Any help in terms of a sample report will be greatly appreciated. My mail id: [email protected]
    Thanks,
    Bharat

  • State chart without NI state chart module

    I have read the design article on state machines in Labview in http://zone.ni.com/devzone/cda/tut/p/id/3024 and gone through the cannon and coin machine examples. I am attempting to build my own state machine (have the state machine diagram as well as the states of my i/o laid out, which will be attached later) without the state chart module b/c I don't think my model is complex enough to justify the purchase. However, after reading the design article, I still don't quite understand how to use the digital logic function palettes to link between each state of my state machine using the status of the inputs. Does anyone have any insight on how to get started on this as I'm still confused after going through the examples?

    No problem, happens once in a while. My post just ensures that all answers will be in the same thread.
    LabVIEW Champion . Do more with less code and in less time .

  • How to move to the next Selected Item in a list.

    *Edited*
    I was just wondering how I could make a button which would move the currently selected item to the next in the array loaded into a List component. I would think to do it through AS or an event, but I'm not sure what I would reference in accordance to that component. The help would be appreciated, thank you.

    You can set the selectedIndex. When next button is clicked increment the selectedIndex.
    If( list.selectedIndex < list.dataProvider.length - 1 )
         list.selectedIndex++;

  • Set the state of an interactive button

    I would like to use interactiev buttons in my document, but set the state on each page so it seems like it is selected (similar to a web page). Is there a way to do this easily? I cannot seem to get it to stic when I export as a pdf. On screen it looks like the ocrrect state is active, but when I save as a pdf with interactivity selected, it goes away... Please help. I am attaching a pdf. I would like on the first page first button the state would be the "on click" state (reverse blue text on white), and then on page two the same

    I guess you should create two separate buttons, one for normal state, another for clicked state. Place them stacked, normal state on the top. Then you place a Hide Button action to it. When user clicks it, it hides itself and clicked state button becomes visible....
    (haven´t tried this, I just guess it could work....)

  • How to use in italy an airport extreme base bought in the states?

    I have received as a gift an Airport Extreme base bought in the States and it doesn't work well. In few words it happens that the connection with the modem is discontinue. Maybe it's because it was built to be used in an "american" environment. Is there someone that can help me to understand if an US base cannot be used in Europe or what can I do to set up correctly the base? Thx a lot. Massimo
    Product: Airport Extreme
    Version: 7.7.3
    Modem: ADB Broadband DA2200

    You will simply plug the Extreme into the main router by ethernet.
    Setup the Extreme to bridge mode.
    Whatever the airport utility chooses which can be wrong.. simply press edit when it is finished.
    Change the Network setup to bridge.
    And for wireless I recommend you select a manual channel for 5ghz.. because the US model is set to North America and does not have any settings for Europe. You need to set the AE to something that overlaps.
    See the WLAN wiki and the chart for 5ghz.
    http://en.wikipedia.org/wiki/List_of_WLAN_channels
    2.4ghz won't be a problem.. US is a subset of Europe.. but 5ghz are markedly different.
    Apple provide no way to change regions.

  • Is there a change history for the STAT retention setting?

    I've been told that the setting that controls the retention period for the STAT files is maintained by the ST03 transaction.  (Export Mode / Collector and Performance DB / Workload Collector / Control Data.)
    Is there any kind of change history kept on this setting, or any way to look at what this setting was in the past?  We are on SAP Basis version SAPKB62061.
    We had this setting originally configured to 72 hours in order to allow us a longer recovery time for problems with FireFighter activity capture.  Now the setting is at 48 hours.  This has actually caused us to be missing some FF activity.  Had some failures on the FF Log Update job from last Friday night and when I went in to manually run the job to capture the missing FF activity, the STAT data is missing.
    Need to see if I can determine who changed the setting, and when.
    Thanks.

    Welcome to the Apple Community William.
    Unfortunately, there isn't anything like that available to you.

  • How would you change the state to the base state?

    How would you change the state to the base state? Its not
    letting me do something like:
    currentState='<Base State>';

    Sorry about the vagueness of that last reply :)
    What I have done now in my code is this:
    viewstack1.addChildAt(loginCanvas,0);
    toggle.selectedIndex = 0;
    However nothing happens at this line of code:
    toggle.selectedIndex = 0;
    but this works:
    toggle.selectedIndex = 1; or ...
    toggle.selectedIndex = 2;
    toggle.selectedIndex = 3;
    toggle.selectedIndex = 4;
    toggle.selectedIndex = 5;
    toggle.selectedIndex = 6;
    The strange thing is that if I have a button on the screen:
    <mx:Button x="10" y="3" label="Button"
    click="toggle.selectedIndex =0"/>
    and the user clicks it the toggle.selectedIndex = 0; works.
    I'm stumped, any ideas?

  • Is it possible to capture the state of a button outside of capturing events?

    I was wondering if there was a way in Flex to determine the state of a button (i.e. up, down, over, selected, etc..) besides capturing each individual events.  What I am asking is essentially to be able to access the "phase" private member variable of the Button class.  Please advise.

    Actually, nevermind, I was mistaken that the Button.phase parameter was private, it is actually of mx_internal type.  Thanks.

Maybe you are looking for

  • Problems with square root approximations with loops program

    i'm having some trouble with this program, this loop stuff is confusing me and i know i'm not doing this correctly at all. the expected values in the tester are not matching up with the output. i have tried many variations of the loop in this code ev

  • How to view uncommited data from other session

    Hi I want to see data that is incommited from other sql session. How can I see it? Generally After commit data is available to other sessions. Please answer me ASAP. Wating for reply Jigar,

  • When MacBook crashes it takes my settings with it.

    I've had an intermittent problem that is eluding me.  This is particularly frustrating because I thought switching from Winders to Mac would provide a more stable experience.  I'm not impressed up to this point. At random intervals (seriously, I have

  • Sap Netweaver 2004 certification

    Hi everyone, I have 2+ years of exp in sap basis , I was thinking about giving the Netweaver 2004 certification please guide me regarding the same i saw the details for it in service.sap.com/education but i guess it was for freshers and the expense i

  • Favorite effects gone every time I start FCP

    This is getting frustrating... Every time I launch FCP 5, it treats me as a first time user. It looks like my preferences are not saving when I log out and shut down. I have created a new user account and have been using that for a week, but this mor