WPF功能区Fluent:DropDownButton + Caliburn.Micro事件 [英] WPF Ribbon Fluent:DropDownButton + Caliburn.Micro event

查看:273
本文介绍了WPF功能区Fluent:DropDownButton + Caliburn.Micro事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Caliburn.Micro在WPF应用程序中使用Fluent功能区控件中的DropDownButton。

I'm trying to use a DropDownButton from the Fluent ribbon control in a WPF application using Caliburn.Micro.

到目前为止,一切都很好。我在DropDownButton中看到一个名为GalleryItems的独角兽列表。
唯一的问题是我无法使 ShowUnicorn()正常工作。
当我从DropDownButton列表中单击某个项目时,它什么也不做。
我做错了吗?

So far, everything is good. I see a list of my Unicorns as GalleryItems in the DropDownButton. The only problem is that I could not get the "ShowUnicorn()" working. When I click on an item from the DropDownButton's list it does nothing. Am I doing something wrong?

这是我使用的代码:

<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>

谢谢。

推荐答案

感谢@Charleh的提示(我对此一无所知)
我在这里找到了一个很好的答案:
https://stackoverflow.com/a/18980558/187650

Thanks @Charleh for the hint (I really had no clue about it) I found a good answer here: https://stackoverflow.com/a/18980558/187650

我也用按钮更改了Fluent:GalleryItem:

Also I changed the Fluent:GalleryItem with a Button:

<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>

这篇关于WPF功能区Fluent:DropDownButton + Caliburn.Micro事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆