September 2012
Intermediate to advanced
464 pages
10h 55m
English
As we saw in the previous recipe, Using logical resources, binding to a resource is achieved in XAML by using the StaticResource markup extension. But what happens if we replace a specific resource? Would that be reflected in all objects using the resource? And if not, can we bind to the resource dynamically?
Make a copy of the previous recipe project CH02.SimpleResources, or create a new project named CH02.DynamicVsStatic and copy the Window XAML contents from the previous project to the new one.
We'll replace StaticResource with DynamicResource and see the effect:
MainWindow.xaml. Add a button to the end of the StackPanel labeled Replace brush and connect it to an event ...