WPF,访问资源字典为什么报错呢?
新建一个资源字典Dictionary1:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="aa">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border Background="Red">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
在项目中使用:
<Window x:Class="WPF3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="800" Width="1105">
<Window.Resources>
<Control x:Key="样式1" Style="{DynamicResource aa}">
<Control.Resources>
<ResourceDictionary Source="pack://application:,,,/WPF3;component/Dictionary1.xaml"/>
</Control.Resources>
</Control>
<Style x:Key="样式2">
<Setter Property="Control.Template" >
<Setter.Value>
<ControlTemplate>
<Grid>
<Control Style="{DynamicResource aa}">
<Control.Resources>
<ResourceDictionary Source="pack://application:,,,/WPF3;component/Dictionary1.xaml"/>
</Control.Resources>
</Control>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
</Window>
在项目中访问资源字典的时候,有两个样式,都是访问同一个资源文件,可是为什么样式1没有报错,
样式2却报这样的错误:无法将类型为“System.Windows.ResourceDictionary”的对象强制转换为类型“Microsoft.Expression.Markup.DocumentModel.DocumentCompositeNode” --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 帮顶. --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 绑定. --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- 有人知道吗??...... --------------------编程问答-------------------- 帮顶 --------------------编程问答-------------------- 有人知道吗??...... --------------------编程问答-------------------- 此问题这么难吗? --------------------编程问答-------------------- 有人知道吗??...... --------------------编程问答-------------------- 顶... --------------------编程问答-------------------- 有人知道吗??...... --------------------编程问答--------------------
--------------------编程问答-------------------- 有人知道吗??..... --------------------编程问答-------------------- 鬼服........ --------------------编程问答-------------------- 你到这里问问看,http://www.silverlightchina.net, --------------------编程问答-------------------- 有人知道吗??..... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 顶一个... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 除 --------------------编程问答-------------------- --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 你样式二是不是调用了什么取值方法导致格式不一致啊? --------------------编程问答--------------------
没有啊,所有的代码都在顶楼,你可以照搬试试 --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 帮顶也遇到过不知道为什么 --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 有人知道吗??... --------------------编程问答-------------------- 你是编译就报错吗? --------------------编程问答--------------------
没有编译,就显示错误 --------------------编程问答-------------------- 不会..帮你顶一个... --------------------编程问答--------------------
我这里是可以的,没有显示错误。 --------------------编程问答--------------------
你是编译就报错吗?
没有编译,就显示错误
我这里是可以的,没有显示错误。
你没有像下面这样显示错误的吗?
--------------------编程问答-------------------- 有人知道吗? --------------------编程问答-------------------- 有人知道吗? --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 有人知道吗? --------------------编程问答-------------------- 我说不上来为何?感觉是节点值取不到,但你将这个放在App里就正常。 --------------------编程问答-------------------- 有人知道吗?
补充:.NET技术 , C#