当我在主应用程序(Application.xaml)上添加资源时,我的页面不会加载其设计查看器,因为它告诉我一个资源(DesignerItem.xaml)中存在错误。否则在运行时它可以很好地工作。
Application.xaml:
<Application xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
x:Class="GesHoras.App"
StartupUri="WinMain.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--Vista Theme -->
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml" />
<ResourceDictionary Source="Themes/TabControl.xaml"/>
<ResourceDictionary Source="Themes/TabItem.xaml"/>
<ResourceDictionary Source="Themes/GridView.xaml"/>
<ResourceDictionary Source="Themes/ListView.xaml"/>
<ResourceDictionary Source="Themes/Button.xaml"/>
<ResourceDictionary Source="Themes/RepeatButton.xaml"/>
<ResourceDictionary Source="Themes/GroupBox.xaml"/>
<ResourceDictionary Source="Themes/TextBox.xaml"/>
<ResourceDictionary Source="Themes/ComboBox.xaml"/>
<ResourceDictionary Source="Themes/TreeView.xaml"/>
<!--<ResourceDictionary Source="Themes/Menu.xaml"/>-->
<ResourceDictionary Source="Themes/ProgressBar.xaml"/>
<ResourceDictionary Source="Themes/ToolTip.xaml"/>
<ResourceDictionary Source="Designer_Controls/DesignerItem.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
和我的DesignerItem.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:GesHoras.Designer_Controls">
<!-- Resource dictionary entries should be defined here. -->
<!-- DragThumb Default Template -->
<Style TargetType="{x:Type s:DragThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:DragThumb}">
<Rectangle Fill="Transparent"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- DesignerItem Style -->
<Style TargetType="{x:Type s:DesignerItem}">
<Setter Property="MinWidth" Value="20"/>
<Setter Property="MinHeight" Value="15"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:DesignerItem}">
<Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
<!-- PART_DragThumb -->
<s:DragThumb x:Name="PART_DragThumb" Cursor="Hand"/>
<!-- PART_ContentPresenter -->
<ContentPresenter x:Name="PART_ContentPresenter"
Content="{TemplateBinding ContentControl.Content}"
Margin="{TemplateBinding ContentControl.Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
它告诉我错误是在DesignerItem.xaml中的行:
<Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
出现的消息错误是:
属性'Path'没有值
有人可以帮我吗?
谢谢!
答案 0 :(得分:0)
DesignerItem.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:GesHoras.Designer_Controls">
<!-- Resource dictionary entries should be defined here. -->
<!-- DragThumb Default Template -->
<Style TargetType="{x:Type s:DragThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:DragThumb}">
<Rectangle Fill="Transparent"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- DesignerItem Style -->
<Style TargetType="{x:Type s:DesignerItem}">
<Setter Property="MinWidth" Value="20"/>
<Setter Property="MinHeight" Value="15"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:DesignerItem}">
<Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
<!-- PART_DragThumb -->
<s:DragThumb x:Name="PART_DragThumb" Cursor="Hand"/>
<!-- PART_ContentPresenter -->
<ContentPresenter x:Name="PART_ContentPresenter"
Content="{TemplateBinding ContentControl.Content}"
Margin="{TemplateBinding ContentControl.Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
问题在于:
<Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
它告诉我路径缺失或没有价值。
谢谢!