Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight 2: XamlParseException in Silverlight 2
    primarykey
    data
    text
    <p>I have the following problem that appears in Silverlight 2; in Silverlight 3 the same code works OK.</p> <p>The XAML code is the following:</p> <pre><code>&lt;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"&gt; &lt;UserControl.Resources&gt; &lt;ControlTemplate x:Key="TopicItem"&gt; &lt;Grid x:Name="TopicItemHost" ShowGridLines="False" Margin="0,8" VerticalAlignment="Stretch"&gt; &lt;vsm:VisualStateManager.VisualStateGroups&gt; &lt;vsm:VisualStateGroup x:Name="CommonStates"&gt; &lt;vsm:VisualState x:Name="Normal" /&gt; &lt;vsm:VisualState x:Name="MouseOver"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="hotRect" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopicItemHost" Storyboard.TargetProperty="Cursor" Duration="0"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0"&gt; &lt;DiscreteObjectKeyFrame.Value&gt; &lt;Cursors&gt;Hand&lt;/Cursors&gt; &lt;/DiscreteObjectKeyFrame.Value&gt; &lt;/DiscreteObjectKeyFrame&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;/vsm:VisualStateGroup&gt; &lt;vsm:VisualStateGroup x:Name="FocusStates"&gt; &lt;vsm:VisualState x:Name="Unfocused" /&gt; &lt;vsm:VisualState x:Name="Focused"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="focusRect" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;/vsm:VisualStateGroup&gt; &lt;vsm:VisualStateGroup x:Name="ReadUnreadStates"&gt; &lt;vsm:VisualState x:Name="Read" /&gt; &lt;vsm:VisualState x:Name="Unread"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopicTitle" Storyboard.TargetProperty="FontWeight" Duration="0"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0"&gt; &lt;DiscreteObjectKeyFrame.Value&gt; &lt;FontWeight&gt;Bold&lt;/FontWeight&gt; &lt;/DiscreteObjectKeyFrame.Value&gt; &lt;/DiscreteObjectKeyFrame&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;/vsm:VisualStateGroup&gt; &lt;/vsm:VisualStateManager.VisualStateGroups&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto" MinWidth="10"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Rectangle x:Name="focusRect" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="2" Fill="#F0F0F0" Margin="0,-8" Opacity="0"/&gt; &lt;Rectangle x:Name="hotRect" Grid.Column="1" Height="1" Margin="0,0,0,0" VerticalAlignment="Bottom" Opacity="0" &gt; &lt;Rectangle.Fill&gt; &lt;LinearGradientBrush StartPoint="0,0" EndPoint="1,0"&gt; &lt;GradientStop Color="#4080C0" Offset="0" /&gt; &lt;GradientStop Color="Gray" Offset="0.5" /&gt; &lt;GradientStop Color="White" Offset="1" /&gt; &lt;/LinearGradientBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;Image x:Name="TopicLock" Grid.Column="0" Visibility="Collapsed" Stretch="None" Source="Images/locked.png" Margin="10,2,10,0" VerticalAlignment="Top" /&gt; &lt;discussion:ThreadListItemTitleHost Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Stretch"&gt; &lt;discussion:TextCut x:Name="TopicTitle" Padding="0,0" Foreground="#4080C0" HorizontalAlignment="Left" VerticalAlignment="Top"/&gt; &lt;discussion:TextCut x:Name="TopicBody" Padding="4,0" VerticalAlignment="Top" HorizontalAlignment="Left" Foreground="Gray"/&gt; &lt;/discussion:ThreadListItemTitleHost&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;ControlTemplate x:Key="ProjectItem"&gt; &lt;TextBlock x:Name="Project" Padding="10,8" VerticalAlignment="Top" TextWrapping="Wrap"/&gt; &lt;/ControlTemplate&gt; &lt;ControlTemplate x:Key="MessagesItem"&gt; &lt;TextBlock x:Name="Messages" Padding="10,8" VerticalAlignment="Top"/&gt; &lt;/ControlTemplate&gt; &lt;ControlTemplate x:Key="AuthorItem"&gt; &lt;discussion:TextCut x:Name="Author" Padding="10,8" VerticalAlignment="Top" HorizontalAlignment="Stretch"/&gt; &lt;/ControlTemplate&gt; &lt;ControlTemplate x:Key="DateItem"&gt; &lt;TextBlock x:Name="Date" Padding="10,8" VerticalAlignment="Top" /&gt; &lt;/ControlTemplate&gt; &lt;ControlTemplate x:Key="BottomBorder"&gt; &lt;Rectangle Width="Auto" Height="0.5" VerticalAlignment="Bottom" Stroke="Gray" StrokeThickness="0.5" /&gt; &lt;/ControlTemplate&gt; &lt;/UserControl.Resources&gt; </code></pre> <p></p> <p>So, there is a control named "TopicTitle" in the XAML. Class TextCut that implements the control contains property "FontWeight":</p> <pre><code>public static readonly DependencyProperty FontWeightProperty = DependencyProperty.RegisterAttached( "FontWeight", typeof(FontWeight), typeof(TextCut), new PropertyMetadata(new PropertyChangedCallback(OnFontWeightPropertyChanged))); </code></pre> <p>Then I call "VisualStateManager.GoToState(ctrl, "Unread", false)". This call should set value Bold into property "FontWeight" of the control "TopicTitle".</p> <p>On Silverlight 2.0 the following exception happens:</p> <p>XamlParseException: LineNumber: 0 LinePosition: 0 Message: "[Line:0 Position:0]" The call stack was: MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.Storyboard_SeekAlignedToLastTick(Storyboard storyboard, Single seekTime) at System.Windows.Media.Animation.Storyboard.SeekAlignedToLastTick(TimeSpan offset) at System.Windows.VisualStateGroup.StartNewThenStopOld(FrameworkElement element, Storyboard[] newStoryboards) at System.Windows.VisualStateManager.GoToStateInternal(Control control, FrameworkElement element, VisualStateGroup group, VisualState state, Boolean useTransitions) at System.Windows.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions)</p> <p>On Silverlight 3.0, as I said, there are no problems. The question is: what happens on Silverlight 2.0 and how can avoid this? What is the "[Line:0 Position:0]" - it tells nothing to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload