gpt4 book ai didi

WPF 功能区 ImageSource

转载 作者:行者123 更新时间:2023-12-03 06:06:47 26 4
gpt4 key购买 nike

我尝试做一个功能区工具栏。我的问题是它没有找到 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-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>

我还声明了 MainWindow.xaml.cs,如下所示:

public partial class MainWindow : RibbonWindow

消息错误是找不到 Mydirectory/BooksDemo/Image 的路径。

为什么它不起作用。有人可以帮我吗?

最佳答案

使用这个:

<RibbonButton LargeImageSource="pack://application:,,,/your_assembly_name;component/Images/grid.png" Label="Book Grid" /> 

您必须将 your_ assembly_name 替换为不带扩展名的程序集名称。

编辑:

此外,通过将“构建操作”字段设置为“资源”,确保您的图像在文件参数中构建为“资源”: enter image description here

关于WPF 功能区 ImageSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35015076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com