Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.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# 从一个资源字典中获取一个资源,该资源字典具有一个键_C#_.net_Wpf_Xaml_Resourcedictionary - Fatal编程技术网

C# 从一个资源字典中获取一个资源,该资源字典具有一个键

C# 从一个资源字典中获取一个资源,该资源字典具有一个键,c#,.net,wpf,xaml,resourcedictionary,C#,.net,Wpf,Xaml,Resourcedictionary,我需要将单个文件中的资源放入一个ResourceDictionary元素中,并使用不同的ResourceDictionary键 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly

我需要将单个文件中的资源放入一个ResourceDictionary元素中,并使用不同的ResourceDictionary键

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
下一个代码是以下示例:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 

删除文书
myvalue2
我想知道在定义元素内容时,是否可以访问指示键的ResourceDictionary:
前面的代码在_Conf_Delete_instr上抛出一个错误,因为找不到

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
如何使用“配置”键访问ResourceDictionary中包含的资源配置删除指令?用转换器

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
谢谢

举个例子:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
  <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary x:Name="Configuration">
                    <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
                </ResourceDictionary>
                <ResourceDictionary x:Name="Report">
                    <sys:String x:Key="mykey2">myvalue2</sys:String>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>

删除文书
myvalue2
测试

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
<Button x:Name="btnDeleteInst" Content="{DynamicResource mykey2}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

<Button x:Name="btnDeleteInst1" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

结果

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
<Button x:Name="btnDeleteInst" Content="{DynamicResource mykey2}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

<Button x:Name="btnDeleteInst1" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />
举个例子:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
  <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary x:Name="Configuration">
                    <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
                </ResourceDictionary>
                <ResourceDictionary x:Name="Report">
                    <sys:String x:Key="mykey2">myvalue2</sys:String>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>

删除文书
myvalue2
测试

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
<Button x:Name="btnDeleteInst" Content="{DynamicResource mykey2}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

<Button x:Name="btnDeleteInst1" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

结果

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/> 
<Button x:Name="btnDeleteInst" Content="{DynamicResource mykey2}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

<Button x:Name="btnDeleteInst1" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" />

尝试将其他ResourceDictionary嵌套在
MergedDictionaries
Hi中。谢谢你的回复。我需要一个单一的资源文件。如果我将其他resourceDictionarys元素(带key)嵌套在mergeddictionaris中,则会出现以下错误:“key属性只能用于嵌入Idictionary类型属性的标记中”。谢谢。请尝试将您的其他ResourceDictionary嵌套在
MergedDictionaries
Hi中。谢谢你的回复。我需要一个单一的资源文件。如果我将其他resourceDictionarys元素(带key)嵌套在mergeddictionaris中,则会出现以下错误:“key属性只能用于嵌入Idictionary类型属性的标记中”。谢谢
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary x:Key="Configuration">
        <sys:String x:Key="_Conf_Delete_instr">Delete instrument</sys:String>
  </ResourceDictionary>
<ResourceDictionary x:Key="Report">
        <sys:String x:Key="mykey2">myvalue2</sys:String>
  </ResourceDictionary>
</ResourceDictionary>


I wonder if when defining the content of an element can access the ResourceDictionary indicating the key:

   <Button x:Name="btnDeleteInst" Content="{DynamicResource _Conf_Delete_instr}" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="0,23,245,0" HorizontalAlignment="Right" Height="50" MinWidth="100" VerticalContentAlignment="Center" Click="btnDeleteInstr_Click"/>