在流利的功能区按钮

时间:2015-12-20 16:08:26

标签: wpf vb.net visual-studio-2013 fluent-ribbon

我想尝试流利的色带控制。这就是我下载它并添加到我的wpf项目的原因。我的xaml代码是

<Fluent:RibbonWindow x:Class="Fluent.Sample.Foundation.Window"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"     
    Title="Fluent.Sample.Foundation" Width="800" Height="600" WindowStartupLocation="CenterScreen" >


    <Fluent:Ribbon>
        <!--Backstage-->
        <Fluent:Ribbon.Menu>
            <Fluent:Backstage></Fluent:Backstage>
        </Fluent:Ribbon.Menu>
        <!--Tabs-->
        <Fluent:RibbonTabItem Header="Tab">
            <Fluent:RibbonGroupBox Header="Group">
                <Fluent:Button Name="buttonGreen" Header="Green" Icon="Images\Green.png" LargeIcon="Images\GreenLarge.png" Click="btnClick" />
                <Fluent:Button Name="buttonGray" Header="Grey" Icon="Images\Gray.png" LargeIcon="Images\GrayLarge.png" />
            </Fluent:RibbonGroupBox>
        </Fluent:RibbonTabItem>
    </Fluent:Ribbon>

</Fluent:RibbonWindow> 

我在这样的流畅功能区按钮上添加了点击事件。

Class MainWindow 
    Private Sub btnClick(sender As Object, e As RoutedEventArgs)
        MsgBox("test")
    End Sub
End Class

但我得到了这个错误。

Type 'Fluent.RibbonWindow' is not defined.
Type 'Fluent.Button' is not defined.
'btnClick' is not a member of 'TestRibbon.Fluent.Sample.Foundation.Window'. 

当我将 Fluent.RibbonWindow 更改为 Global.Fluent.RibbonWindow 时,与 Fluent.Button 相同,它运作良好并且过了一段时间它再次显示相同的错误,我无法理解为什么发生此错误'btnClick'不是'TestRibbon.Fluent.Sample.Foundation.Window'的成员。

任何人都可以帮我解决这个问题吗?感谢。

1 个答案:

答案 0 :(得分:1)

您是否尝试将以下内容添加到资源中?请查看https://github.com/fluentribbon/Fluent.Ribbon的演练。

<Ribbon:RibbonWindow.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <!--Attach Default Fluent Control's Theme-->
            <ResourceDictionary Source="/Fluent;Component/Themes/Generic.xaml" />
            <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml" />
            <!--<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/office2013/generic.xaml" />-->
        </ResourceDictionary.MergedDictionaries>                       
    </ResourceDictionary>        
</Ribbon:RibbonWindow.Resources>