I was hoping to use dynamic background images with Caliburn.Micro. This is what I have tried without success.
<Grid>
<Grid.Background>
<ImageBrush x:Name="MyPhoto" />
</Grid.Background>
</Grid>
//some view model
public class ImageViewModel
{
public ImageSource MyPhoto {get;set;}
}
//Add Convention
//App.XAML.cs
...
public override void Configure()
{
...
ConventionManager.AddElementConvention<ImageBrush>(ImageBrush.ImageSourceProperty, "ImageSource", "Loaded");
...
}
Is it possible to bind and ImageBrush's ImageSource with Caliburn.Micro or is there a better way to do this?
Not sure but I think
AddElementConvention
works only forUIElement
s notDependencyObject
s. This should work, though:MainPage.xaml
:MainPageViewModel.cs
:App.xaml.cs
:Alternatively you could do the binding by hand in XAML: