WPF用户控件和WinForm不显示图标

时间:2013-06-23 10:27:34

标签: wpf winforms

我正在尝试使用WinForm将WPF用户控件放在ElementHost上,但由于我的图标没有显示在按钮上。

http://gyazo.com/7dc201e30246b2b2676060de0ebf35a9

http://gyazo.com/67f039ce310d17a2d270c816ebc5fb3b

<ToolBar>
    <Button>
        <StackPanel Orientation="Horizontal">
            <Image Source="pack://siteoforigin:,,,/Resources/document-add2.png"  Stretch="None" Margin="0,0,3,0" />
                <TextBlock>Добавить стратегию</TextBlock>
        </StackPanel>
    </Button>

    <Button>
        <StackPanel Orientation="Horizontal">
            <Image Source="pack://siteoforigin:,,,/Resources/document-delete2.png"  Stretch="None" Margin="0,0,3,0" />
            <TextBlock>Удалить стратегию</TextBlock>
        </StackPanel>
    </Button>

    <Separator></Separator>

    <Button>
        <StackPanel Orientation="Horizontal">
            <Image Source="pack://siteoforigin:,,,/Resources/document-control_play.png"  Stretch="None" Margin="0,0,3,0" />
            <TextBlock>Запустить стратегию</TextBlock>
        </StackPanel>
    </Button>

    <Separator></Separator>

    <Button>
        <StackPanel Orientation="Horizontal">
            <Image Source="pack://siteoforigin:,,,/Resources/document-gear.png"  Stretch="None" Margin="0,0,3,0" />
            <TextBlock>Изменить настройки</TextBlock>
        </StackPanel>
    </Button>
</ToolBar>

1 个答案:

答案 0 :(得分:0)

您是否指定了siteoforigin

如果可以在同一项目中找到图像,请尝试:

<Button>
    <StackPanel Orientation="Horizontal">
        <Image Source="pack://application:,,,/Resources/document-gear.png"  Stretch="None" Margin="0,0,3,0" />
        <TextBlock>Изменить настройки</TextBlock>
    </StackPanel>
</Button>

所以:pack://application:,,,/[path from root of project]