I add button to Hospital Floor sample and want to change fill color in one bed. On click event I have these code
var vm = (HospitalFloorPlanViewModel)DataContext;
IEnumerable<TestFloor.ViewModels.MapElementViewModel> mevm = vm.MapElements;
HospitalFloorPlanViewModel hfvm = new HospitalFloorPlanViewModel();
hfvm.ChangeColor(mevm);
Here is ChangeColor function in HospitalFloorPlanViewModel class
public void ChangeColor(IEnumerable<MapElementViewModel> ele){ var t = ele.FirstOrDefault(x => x.Name == "0");
t.Fill = new SolidColorBrush(Colors.Red);}
The problem is bed color not refreshing unless I Check/uncheck one of the filter checks (bed Status filter). I tried to use bedLayer.ImportAsync();, but it's not working for me. How can I refresh one map element?
Thanks
Great!, Thank you very much.
One way is to use DispatcherTimer:
var dt = new DispatcherTimer();Brush fill = null;dt.Interval = TimeSpan.FromSeconds(1.0);dt.Tick += (dtSender, dtEventArgs) => { var vm = (HospitalFloorPlanViewModel)DataContext;
IEnumerable<ViewModels.MapElementViewModel> mevm = vm.MapElements;
if (fill == null) { fill = new SolidColorBrush(Colors.Red); } else { fill = null; }
hfvm.ChangeColor(mevm, fill); xamMap.Layers["bedLayer"].DataBind(); };
dt.Start();
Thanks Ivan! It worked. Can you help me not just change color, but make it blinking?
Hi arkgroup,
Try to call bedLayer's DataBind method, afterChangeColor call, e.g.:
xamMap.Layers["bedLayer"].DataBind();
Regards,
Ivan Kotev