I want to use a VisualBrush in App.xaml:
<Application.Resources>
<VisualBrush x:Key="TestBrush1" />
<VisualBrush x:Key="TestBrush2" />
</Application.Resources>
Then I want to set a binding in one window like this:
VisualBrush testBrush = (VisualBrush)FindResource("TestBrush1");
Binding testBinding = new Binding();
testBinding.Source = FirstBrowser;
testBrush.Visual = testBinding;
And then I want to use this Brush to show the content of the FirstBrowser to another window. But that would come later. The binding does not work this way. Has someone an idea how I can make this work?
You cannot modify a VisualBrush that you have defined in App.xaml because it is frozen automatically by the runtime so defining a VisualBrush without a Visual as a global resource is useless.
You better create a new brush when you actually need it. You can bind the Visual property of a VisualBrush using the
BindingOperations.SetBindingmethod like this: