Wpf 带状影像源
我试着做一个功能区工具栏。我的问题是它没有找到ImageSource。 以下是我的简单代码:Wpf 带状影像源,wpf,xaml,ribbon,imagesource,Wpf,Xaml,Ribbon,Imagesource,我试着做一个功能区工具栏。我的问题是它没有找到ImageSource。 以下是我的简单代码: <RibbonWindow x:Class="BooksDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr
<RibbonWindow x:Class="BooksDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BooksDemo"
Title="Books Demo App" Height="400" Width="600">
<Ribbon DockPanel.Dock="Top" >
<Ribbon.QuickAccessToolBar>
<RibbonQuickAccessToolBar>
<RibbonButton Command="local:BooksCommands.ShowBook" />
<RibbonButton Command="local:BooksCommands.ShowBooksList" />
</RibbonQuickAccessToolBar>
</Ribbon.QuickAccessToolBar>
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu >
<RibbonApplicationMenuItem Header="Show _Book" />
<RibbonSeparator />
<RibbonApplicationMenuItem Header="Exit" Command="Close" />
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab Header="Home">
<RibbonGroup Header="Clipboard">
<RibbonButton Command="Paste" Label="Paste" SmallImageSource="Images/cut.png" />
<RibbonButton Command="Cut" SmallImageSource="Images/cut.png" />
<RibbonButton Command="Copy" SmallImageSource="Images/copy.png" />
<RibbonButton Command="Undo" LargeImageSource="Images/undo.png" />
</RibbonGroup>
<RibbonGroup Header="Show">
<RibbonButton LargeImageSource="Images/one.png" Label="Book" />
<RibbonButton LargeImageSource="Images/list.png" Label="Book List" />
<RibbonButton LargeImageSource="Images/grid.png" Label="Book Grid" />
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="Ribbon Controls">
<RibbonGroup Header="Sample">
<RibbonButton Label="Button" />
<RibbonCheckBox Label="Checkbox" />
<RibbonComboBox Label="Combo1">
<Label>One</Label>
<Label>Two</Label>
</RibbonComboBox>
<RibbonTextBox>Text Box</RibbonTextBox>
<RibbonSplitButton Label="Split Button">
<RibbonMenuItem Header="One" />
<RibbonMenuItem Header="Two" />
</RibbonSplitButton>
<RibbonComboBox Label="Combo2" IsEditable="False">
<RibbonGallery SelectedValuePath="Content" MaxColumnCount="1" SelectedValue="Green">
<RibbonGalleryCategory>
<RibbonGalleryItem Content="Red" Foreground="Red" />
<RibbonGalleryItem Content="Green" Foreground="Green" />
<RibbonGalleryItem Content="Blue" Foreground="Blue" />
</RibbonGalleryCategory>
</RibbonGallery>
</RibbonComboBox>
</RibbonGroup>
</RibbonTab>
</Ribbon>
消息错误是找不到Mydirectory/BooksDemo/Image的路径
为什么它不起作用。有人能帮帮我吗。用这个:
<RibbonButton LargeImageSource="pack://application:,,,/your_assembly_name;component/Images/grid.png" Label="Book Grid" />
您必须用程序集名称替换您的程序集名称,而不带扩展名
编辑:
另外,通过将“生成操作”字段设置为“资源”,确保在“文件”参数中将图像生成为资源:
谢谢您的回答,但它不起作用。我注意到,当我逐个ribbon更改RibbonWindow时,它可以识别图像,但当然不起作用@AymenRagoubi您能在这里复制您收到的错误吗?消息错误为“找不到路径“mypath\Images\one.png”的一部分。为什么要在解决方案目录中查找图像?是否应添加对功能区组件的引用?图像文件夹在哪里?它是在您的主组件中还是在另一个单独的组件中?在组件Ribbon控件库中。
<RibbonButton LargeImageSource="pack://application:,,,/your_assembly_name;component/Images/grid.png" Label="Book Grid" />