TreeviewItem CheckState help

2 posts, 0 answers
  1. John Benson
    John Benson avatar
    7 posts
    Member since:
    Aug 2009

    Posted 22 Mar 2010 Link to this post

    I am trying to create logic so that, based on a Boolean value, the user will be unable to "click" a TreeviewItem's check box. Unfortunately, I'm getting all kinds of unexpected behavior.

    Based on some logic (seeing if this Boolean is set to true and seeing the number of selected items), I have an If statement in Treeview_Checked set the TreeviewItem.CheckState to Automation.ToggleState.Off. This works, and then runs through the Treeview_Unchecked code.

    I let the program run until the very last bit of the "Treeview_Checked" snippet where the  e.Source.CheckState is still set to Off. However, as soon as I get back to the GUI interface the checkbox does have a check in it.

    I can't see where this is being set and how I can interrupt it. I tried using the PreviewCheck and PreviewUnchecked events, but neither made a difference.

    I'm using v2009.3.1219.1030 version as the latest release causes other parts of my code to function incorrectly, and would like to be able to stay with the version I am currently using.

    Any suggestions on how I can get the functionality I'm look for? Thanks in advance.


    We decided to go with a different approach. We wiped out the list and then repopulated it with the newly selected item. Thanks to David for getting the creative juices flowing!
  2. David Brubacher
    David Brubacher avatar
    29 posts
    Member since:
    Mar 2010

    Posted 22 Mar 2010 Link to this post

    I have the same application requirements, but I hid the checkbox if the user can't check it, so I don't care what state it's in.
    I also modified the control template so the space for the checkbox remained despite it being hidden.

    Looks good and works well

Back to Top