Программа просмотра XAML не загружается - PullRequest
0 голосов
/ 19 февраля 2010

Когда я добавляю ресурс в мое основное приложение (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}}">

появляется сообщение об ошибке:

Свойство 'Путь' не имеет значения

Может кто-нибудь помочь мне, пожалуйста?

Спасибо!

1 Ответ

0 голосов
/ 22 февраля 2010

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}}">

Он говорит мне, что путь отсутствует или не имеет значения.

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...