Locbaml error when using VisualStateManager in Framework 3.5
When I translated the Tester.WPF.resources.dll, I get an error. It's like the baml file have modified VisualStateGroup to an collection. I don't understand. The poject starts up without any problem in the default language, but if I change the culture, it crashes. I Rebuild it, still that error, even when a start from scratch. With this small test project and still get the same error:
Object of type 'System.Windows.VisualStateGroup' cannot be converted to type 'System.Collections.ObjectModel.Collection`1[System.Windows.VisualStateGroup]'.
StackTrace
at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType) at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.SetClrComplexProperty(Object parentObject, MemberInfo memberInfo, Object o)
at System.Windows.Markup.BamlRecordReader.SetPropertyValueToParent(Boolean fromStartTag, Boolean& isMarkupExtension)
at System.Windows.Markup.BamlRecordReader.ReadElementEndRecord(Boolean fromNestedBamlRecordReader)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Tester.WPF.Window1.InitializeComponent()
TestWindow
<Window x:Class="Arofex.Translator.Tester.WPF.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
xmlns:Controlsw="clr-namespace:System.Windows;assembly=WPFToolkit"
>
<Grid>
<Border x:Name="LayoutRoot" BorderThickness="1" BorderBrush="Red" RenderTransformOrigin="0.5,0.5" Width="500" CornerRadius="5" Margin="0,0,0,30">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<Controlsw:VisualStateManager.VisualStateGroups>
<Controlsw:VisualStateGroup x:Name="VSGVisiblbe">
<Controlsw:VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.2000000"/>
</Controlsw:VisualStateGroup.Transitions>
<Controlsw:VisualState x:Name="StateNormal"/>
<Controlsw:VisualState x:Name="StateStart">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.034"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(开发者_StackOverflow中文版TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="-57"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Controlsw:VisualState>
</Controlsw:VisualStateGroup>
</Controlsw:VisualStateManager.VisualStateGroups>
<StackPanel Orientation="Vertical" Background="LightGray">
<TextBlock Text="My text to test translation" />
</StackPanel>
</Border>
App code
private void Application_Startup(object sender, StartupEventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-BE");
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-BE");
var dictionaryList = new List<Uri>();
foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries)
dictionaryList.Add(dictionary.Source);
Application.Current.Resources.MergedDictionaries.Clear();
foreach (Uri uri in dictionaryList)
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = uri });
}
}
Thanks for any suggestion.
精彩评论