2010-03-05 4 views
2

Silverlight 2에 나타나는 다음과 같은 문제가 있습니다. Silverlight 3에서는 동일한 코드가 제대로 작동합니다.Silverlight 2 : Silverlight 2의 XamlParseException

XAML 코드는 다음과 같습니다

<UserControl x:Class="My_Discussions.ThreadListItem" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
xmlns:discussion="clr-namespace:My_Discussions" 
Width="Auto" Height="Auto">  

<UserControl.Resources> 

    <ControlTemplate x:Key="TopicItem"> 
     <Grid x:Name="TopicItemHost" ShowGridLines="False" Margin="0,8" VerticalAlignment="Stretch"> 
      <vsm:VisualStateManager.VisualStateGroups> 
       <vsm:VisualStateGroup x:Name="CommonStates"> 
        <vsm:VisualState x:Name="Normal" /> 
        <vsm:VisualState x:Name="MouseOver"> 
         <Storyboard> 
          <DoubleAnimation 
            Storyboard.TargetName="hotRect" 
            Storyboard.TargetProperty="Opacity" 
            Duration="0" 
            To="1" /> 
          <ObjectAnimationUsingKeyFrames 
           Storyboard.TargetName="TopicItemHost" 
           Storyboard.TargetProperty="Cursor" 
           Duration="0"> 
           <DiscreteObjectKeyFrame KeyTime="0"> 
            <DiscreteObjectKeyFrame.Value> 
             <Cursors>Hand</Cursors> 
            </DiscreteObjectKeyFrame.Value> 
           </DiscreteObjectKeyFrame> 
          </ObjectAnimationUsingKeyFrames> 
         </Storyboard> 
        </vsm:VisualState> 
       </vsm:VisualStateGroup> 
       <vsm:VisualStateGroup x:Name="FocusStates"> 
        <vsm:VisualState x:Name="Unfocused" /> 
        <vsm:VisualState x:Name="Focused"> 
         <Storyboard> 
          <DoubleAnimation 
            Storyboard.TargetName="focusRect" 
            Storyboard.TargetProperty="Opacity" 
            Duration="0" 
            To="1" /> 
         </Storyboard> 
        </vsm:VisualState> 
       </vsm:VisualStateGroup> 
       <vsm:VisualStateGroup x:Name="ReadUnreadStates"> 
        <vsm:VisualState x:Name="Read" /> 
        <vsm:VisualState x:Name="Unread"> 
         <Storyboard> 
          <ObjectAnimationUsingKeyFrames 
           Storyboard.TargetName="TopicTitle" 
           Storyboard.TargetProperty="FontWeight" 
           Duration="0"> 
           <DiscreteObjectKeyFrame KeyTime="0"> 
            <DiscreteObjectKeyFrame.Value> 
             <FontWeight>Bold</FontWeight> 
            </DiscreteObjectKeyFrame.Value> 
           </DiscreteObjectKeyFrame> 
          </ObjectAnimationUsingKeyFrames> 
         </Storyboard> 
        </vsm:VisualState> 
       </vsm:VisualStateGroup> 
      </vsm:VisualStateManager.VisualStateGroups> 

      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto" MinWidth="10"/> 
       <ColumnDefinition Width="*"/> 
      </Grid.ColumnDefinitions> 

      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto" /> 
       <RowDefinition Height="*" /> 
      </Grid.RowDefinitions> 

      <Rectangle x:Name="focusRect" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="2" Fill="#F0F0F0" Margin="0,-8" Opacity="0"/> 
      <Rectangle x:Name="hotRect" Grid.Column="1" Height="1" Margin="0,0,0,0" VerticalAlignment="Bottom" Opacity="0" 
         > 
       <Rectangle.Fill> 
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> 
         <GradientStop Color="#4080C0" Offset="0" /> 
         <GradientStop Color="Gray" Offset="0.5" /> 
         <GradientStop Color="White" Offset="1" /> 
        </LinearGradientBrush> 
       </Rectangle.Fill> 
      </Rectangle> 

      <Image x:Name="TopicLock" Grid.Column="0" Visibility="Collapsed" 
        Stretch="None" Source="Images/locked.png" Margin="10,2,10,0" 
        VerticalAlignment="Top" /> 

      <discussion:ThreadListItemTitleHost Grid.Column="1" 
               HorizontalAlignment="Left" 
               VerticalAlignment="Stretch"> 
       <discussion:TextCut x:Name="TopicTitle" 
            Padding="0,0" 
            Foreground="#4080C0" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Top"/> 

       <discussion:TextCut x:Name="TopicBody" 
            Padding="4,0" 
            VerticalAlignment="Top" 
            HorizontalAlignment="Left" 
            Foreground="Gray"/> 
      </discussion:ThreadListItemTitleHost> 

     </Grid> 
    </ControlTemplate> 

    <ControlTemplate x:Key="ProjectItem"> 
     <TextBlock x:Name="Project" Padding="10,8" VerticalAlignment="Top" TextWrapping="Wrap"/> 
    </ControlTemplate> 

    <ControlTemplate x:Key="MessagesItem"> 
     <TextBlock x:Name="Messages" Padding="10,8" VerticalAlignment="Top"/> 
    </ControlTemplate> 

    <ControlTemplate x:Key="AuthorItem"> 
     <discussion:TextCut x:Name="Author" Padding="10,8" VerticalAlignment="Top" HorizontalAlignment="Stretch"/> 
    </ControlTemplate> 

    <ControlTemplate x:Key="DateItem"> 
     <TextBlock x:Name="Date" Padding="10,8" VerticalAlignment="Top" /> 
    </ControlTemplate> 

    <ControlTemplate x:Key="BottomBorder"> 
     <Rectangle Width="Auto" Height="0.5" VerticalAlignment="Bottom" Stroke="Gray" StrokeThickness="0.5" /> 
    </ControlTemplate> 

</UserControl.Resources> 

는 그래서, XAML에서 "TopicTitle"라는 이름의 컨트롤이 있습니다. 컨트롤을 구현하는 클래스 TextCut 속성 "글꼴 너비를"포함

public static readonly DependencyProperty FontWeightProperty = DependencyProperty.RegisterAttached(
     "FontWeight", 
     typeof(FontWeight), 
     typeof(TextCut), 
     new PropertyMetadata(new PropertyChangedCallback(OnFontWeightPropertyChanged))); 

가 그럼 난 "VisualStateManager.GoToState (Ctrl 키", "거짓, 읽지 않음)"라고 부릅니다. 이 호출은 컨트롤 "TopicTitle"의 속성 "FontWeight"에 값 Bold를 설정해야합니다. 실버 라이트 2.0 다음과 같은 예외에

이 발생합니다

XamlParseException : LINENUMBER : 0 LinePosition : 0 메시지 : "[선 : 0 위치 : 0]" 호출 스택했다 : MS.Internal. System.Windows.VisualStateGroup.StartNewThenStopOld에서 XcpImports.CheckHResult (UINT32의 시간)에서 System.Windows.Media.Animation.Storyboard.SeekAlignedToLastTick MS.Internal.XcpImports.Storyboard_SeekAlignedToLastTick (스토리 스토리, 단일 seekTime) 에서 (시간 범위 오프셋) (FrameworkElement 요소, 스토리 보드 [] newStoryboards)System.Windows.VisualStateManager.GoToStateInternal (컨트롤 제어 FrameworkElement 요소 VisualStateGroup 기, VisualState 상태 부울 useTransitions) System.Windows.VisualStateManager.GoToState에서 에서(컨트롤 제어 스트링 stateName 부울 useTransitions)에서 실버

3.0에서 말했듯이 문제는 없습니다. 질문은 Silverlight 2.0에서 어떤 일이 발생하며 어떻게이를 피할 수 있습니까? "[Line : 0 Position : 0]"은 무엇입니까? 나에게 아무 것도 말하지 않습니다.

<FontWeight>Bold</FontWeight> 

난 당신이 SL2 고수를위한 좋은 이유가 있어야합니다 확신하지만, - :

답변

0

그럼 내 실버 라이트 2의 지식은 아주 녹슨하지만 난 말하고 싶지만 호출 스택을보고 자사의이 화가 점점 SL3을 사용하는 것이 수정 될 수 있음을 언급하는 것을 도울 수 없습니다.

+0

답변 해 주셔서 감사합니다. ' 굵게'- 무엇이 잘못 되었나요? 내 사용자 정의 컨트롤 대신 TextBlock 컨트롤에 동일한 코드를 적용하려고 시도했습니다.이 방법은 텍스트가 굵게 표시됩니다. – KellyLynch