首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WPF带状ImageSource

WPF带状ImageSource
EN

Stack Overflow用户
提问于 2016-01-26 13:36:17
回答 1查看 2.1K关注 0票数 3

我试着做一个色带ToolBar。我的预言是它找不到ImageSource。以下是我的简单代码:

代码语言:javascript
复制
<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如下:

代码语言:javascript
复制
public partial class MainWindow : RibbonWindow

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

为什么它不起作用。有人能帮帮我吗。

EN

回答 1

Stack Overflow用户

发布于 2016-01-26 13:59:39

用这个:

代码语言:javascript
复制
<RibbonButton LargeImageSource="pack://application:,,,/your_assembly_name;component/Images/grid.png" Label="Book Grid" /> 

您必须用没有扩展名的程序集名称替换your_assembly_name

编辑:

还请通过将Build操作字段设置为Resources,确保在文件参数中将映像构建为参考资料:

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35015076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档