Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将图像插入Generic.xaml_C#_Wpf_Xaml - Fatal编程技术网

C# 如何将图像插入Generic.xaml

C# 如何将图像插入Generic.xaml,c#,wpf,xaml,C#,Wpf,Xaml,我正在使用generic.xaml为我正在创建的应用程序创建母版页,以下是迄今为止的代码: <Style TargetType="{x:Type local:Master}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:Master}">

我正在使用generic.xaml为我正在创建的应用程序创建母版页,以下是迄今为止的代码:

    <Style TargetType="{x:Type local:Master}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:Master}">                   
                <StackPanel>
                    <Menu Height="50" Margin="0,0,0,0" HorizontalAlignment="Stretch" FlowDirection="RightToLeft" Panel.ZIndex="0">
                        <Menu.Background>
                            <LinearGradientBrush EndPoint="0,0" StartPoint="0,1">
                                <GradientStop Color="#FFB3DDF2" Offset="1.0"/>
                                <GradientStop Color="#FFD6E9F4" Offset="0.0"/>
                            </LinearGradientBrush>
                        </Menu.Background>
                    </Menu>                       
                    <Menu Width="350" Height="850" Margin="0,0,0,0" VerticalAlignment="Stretch" HorizontalAlignment="Left" FlowDirection="RightToLeft" DockPanel.Dock="Bottom" Panel.ZIndex="0">
                        <Menu.Background>
                            <LinearGradientBrush EndPoint="0,0" StartPoint="0,1">
                                <GradientStop Color="#FFD6E9F4" Offset="1.0"/>
                                <GradientStop Color="White" Offset="0.0"/>
                            </LinearGradientBrush>
                        </Menu.Background>
                    </Menu> 
                </StackPanel>                                                            
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

我想添加一个图像到这个页面,我已经尝试了很多方法,但找不到正确的方法。有些方法会将图像引入,但会删除我的其他菜单之一


提前感谢。

将图像放在项目中,并将其构建操作设置为
资源
,然后以以下方式引用它:

<Image Source="/YourApplicatioName;component/PathToYourImage/Image.png" />


感谢您的回复,当您说“将其放入项目”时,您是指我的Generic.xaml页面代码吗?@user2979423不,我是指直接在项目内部,只需将图像拖放到应用程序项目中即可