c# - Update CanExecute from another ViewModel's actions -
where run createbestpricelistcanexecute
method in order update canexecute
in below code snippet?
class bestpriceviewmodel : viewmodelbase { observablecollection<bestpricemodel> bestpricelist = new observablecollection<bestpricemodel>(); public icommand createbestpricelistcommand; private bool canexecute = true; public bestpriceviewmodel() { createbestpricelistcommand = new relaycommand(createbestpricelist, param => this.canexecute); btnloaditemlist = "import"; } public observablecollection<bestpricemodel> bestpricelist { { return this.bestpricelist; } set { if (this.bestpricelist != value) { this.bestpricelist = value; this.onpropertychanged("bestpricelist"); } } } public bool canexecute { { return this.canexecute; } set { if (this.canexecute == value) { return; } this.canexecute = value; } } public icommand createbestpricelistcommand { { return createbestpricelistcommand; } set { createbestpricelistcommand = value; } } public bool createbestpricelistcanexecute() { bool dbcheck = databaseaccess.connection.state != connectionstate.open && databaseaccess.connection.state != connectionstate.fetching && databaseaccess.connection.state != connectionstate.executing ? true : false; return dbcheck; } }
my createbestprice
method using database, , has automatic database updater running in background uploads information sometimes. need canexecute
false @ times, there way it?
just update canexecute
property createbestpricelistcanexecute
method:
public void createbestpricelistcanexecute() { canexecute = databaseaccess.connection.state != connectionstate.open && databaseaccess.connection.state != connectionstate.fetching && databaseaccess.connection.state != connectionstate.executing ? true : false; }
then it's how call createbestpricelistcanexecute
method. call dispatchertimer.tick
event handler example.
Comments
Post a Comment