Since a change in MahApps.Metro 1.5.0 the base element of a Flyout was changed from ContentControl
to HeaderContentControl
. Now the MVVM approach with Caliburn.Micro and this suggestion doesn't work anymore.
Has anybody else tried to solve this issue in a nice MVVM way?
While I haven't tried it myself but since the new Flyout
control is now based on HeaderedContentControl
it would be a simple logic choice to attempt to do this instead of the previous, which was based on ContentControl
. Looks like the advantages of this change were the elimination of a couple of dependency properties...
<controls:FlyoutsControl.ItemTemplate>
<DataTemplate>
<HeaderedContentControl cal:View.Model="{Binding}" />
</DataTemplate>
</controls:FlyoutsControl.ItemTemplate>
The other thing that might come out of this that you create a Caliburn.micro convention to actually bind correctly to that HeaderedContentControl
which wouldn't be all that different from the ContentControl
variant was, by default in CM already. What is odd is that this HeaderedContentControl
is derived from ContentControl
in theory it should have been found correctly. Another thing to think about is this actually might also be related to Visual Tree where CM can't see it till it's in the tree, therefore can't bind it.
Content Control convention in CM source as a reference.
I've added posted a work around on GitHub.
It appears there's something going on with setting the ItemTemplate
of the FlyoutsControl
.
来源:https://stackoverflow.com/questions/43735278/wpf-mahapps-metro-caliburn-micro-flyout-headeredcontentcontrol