xaml - WPF Button IsEnabled Bound PropertyChanged Event Not Firing Asynchronously -
i have xaml window button has isenabled property bound boolean property in window's viewmodel.
xaml:
<button isenabled="{binding searchbuttonenabled}" command="{binding search}" content="search" /> viewmodel:
public bool searchbuttonenabled { { return _searchbuttonenabled; } set { if (_searchbuttonenabled != value) { _searchbuttonenabled = value; propertychanged(this, new propertychangedeventargs("searchbuttonenabled")); } } } in viewmodel constructor calling async function populate datagrid:
private async void loadsearchgrid() { string sql = "query takes long time"; sqlcommand gridsourcecommand = new sqlcommand(sql, conn); searchfilters = new displaysearchfiltercollection(); searchbuttonenabled = false; searchgridsource = await getdatatableasync(gridsourcecommand); searchbuttonenabled = true; } now, code giving me issues line:
searchbuttonenabled = true; the line disables searchbuttonenabled property always works, while line enabling works. if replace "query takes long time" "query takes little time" property enabled fine , ui updated accordingly. otherwise button stays disabled. have done research on topic , obvious updating ui can problematic if done on worker thread, haven't found reason why in context. or guidance appreciated.
Comments
Post a Comment