WPF Ribbon Fluent:DropDownButton + Caliburn.Micro event

a 夏天 提交于 2019-12-11 19:02:08

问题


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

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?

This is the code that I use:

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

Thanks in advance.


回答1:


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

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>


来源:https://stackoverflow.com/questions/19679804/wpf-ribbon-fluentdropdownbutton-caliburn-micro-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!