如何在WPF项目中用ResourceDictionary文件中的图像描述WindowCloseButton

如何在WPF项目中用ResourceDictionary文件中的图像描述WindowCloseButton,wpf,imagebutton,resourcedictionary,imagesource,Wpf,Imagebutton,Resourcedictionary,Imagesource,[问题解决了] 我正在开发一个WPF项目。我想为窗口自定义标题。我创建了一个资源字典。但我无法将带有路径的图像添加到资源字典。出现了一些错误。跟我来,我想在这张图上加标题 项目树如图所示: 我怎样才能继续 我已经解决了这个问题。我把静态资源改为动态资源。在那之后它工作了 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schem

[问题解决了]

我正在开发一个WPF项目。我想为窗口自定义标题。我创建了一个资源字典。但我无法将带有路径的图像添加到资源字典。出现了一些错误。跟我来,我想在这张图上加标题


项目树如图所示:

我怎样才能继续

我已经解决了这个问题。我把静态资源改为动态资源。在那之后它工作了

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" >
<!--Strat of my defined codes -->

<Image x:Key="WindowCloseImg" Source="..\Images\Windows\window_kapat.png"/>
<Style  x:Key="WindowCloseButtonStyle" TargetType="{x:Type Button}">
    <Setter Property="Content" Value="{DynamicResource WindowCloseImg}"/>
</Style>

<!-- Modal Window style -->
<Style x:Key="LoginWindowStyle" TargetType="{x:Type Window}">
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
    <Setter Property="WindowStyle" Value="None"/>
    <Setter Property="AllowsTransparency" Value="True"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Template" >
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">
                <Border Background="{TemplateBinding Background}"  BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="20"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <!-- Header -->
                        <Border Grid.Row="0" x:Name="Header" BorderBrush="Transparent" Background="{DynamicResource BackgroundBrush}" BorderThickness="1,1,1,0" CornerRadius="5,5,0,0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="20"/>
                                </Grid.ColumnDefinitions>
                                <Button BorderBrush="Transparent" Style="{StaticResource WindowCloseButtonStyle}" Grid.Column="2" Width="15" Height="15"  x:Name="btnClose" Command="Close"/>

                            </Grid>
                        </Border>