我正在尝试使用Caliburn.Micro在WPF应用程序中使用Fluent功能区控件中的DropDownButton。
到目前为止,一切都很好。我在DropDownButton中看到了我的Unicorns列表作为GalleryItems。 唯一的问题是我无法让“ShowUnicorn()”工作。 当我点击DropDownButton列表中的某个项目时,它什么也没做。 我做错了吗?
这是我使用的代码:
<Fluent:DropDownButton Header="Farm"
LargeIcon="..\..\Resources\unicorn48.png">
<Fluent:Gallery ItemsSource="{Binding AllUnicorns}">
<Fluent:Gallery.ItemTemplate>
<DataTemplate>
<Fluent:GalleryItem Content="{Binding UnicornFoobar}"
cal:Message.Attach="[Event Click] = [Action ShowUnicorn()]" />
</DataTemplate>
</Fluent:Gallery.ItemTemplate>
</Fluent:Gallery>
提前致谢。
答案 0 :(得分:2)
感谢@Charleh提示(我真的不知道它) 我在这里找到了一个好的答案: https://stackoverflow.com/a/18980558/187650
我还使用Button更改了Fluent:GalleryItem:
<Fluent:DropDownButton x:Name="aaaa"
Header="Farm"
LargeIcon="..\..\Resources\unicorn48.png">
<Fluent:Gallery ItemsSource="{Binding AllUnicorns}">
<Fluent:Gallery.ItemTemplate>
<DataTemplate>
<Button Content="{Binding UnicornFoobar}"
cal:Message.Attach="[Event Click] = [Action ShowUnicorn($dataContext)]"
cal:Action.TargetWithoutContext="{Binding DataContext, ElementName=aaaa}" />
</DataTemplate>
</Fluent:Gallery.ItemTemplate>
</Fluent:Gallery>