XamlParseException
HejJeg har et problem, får en XamlParseException i min kode, men der står at det er i line 0, position 0. Fejlen kommer også kun sjældent, er ikke hver gang, og har svært ved at fremprovokere den hver gang.
Grunden til line 0, position 0 er fordi jeg laver min Xaml i c# via en XamlLoader.
Koden ser således ud:
#region
private static readonly string DayDataCellTemplate = @"<DataTemplate
xmlns=""http://schemas.microsoft.com/client/2007""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:converter=""clr-namespace:WorkBook.Client.Converter;assembly=WorkBook.Client""
xmlns:local=""clr-namespace:WorkBook.Client.Views.Scheduling;assembly=WorkBook.Client"">
<Grid>
<Grid.Resources>
<converter:BackGroundConverter x:Key=""BackGroundConverter"" />
<local:CellConverter x:Key=""CellConverter"" />
<local:CellScaleConverter x:Key=""CellScaleConverter"" />
<local:ToolTipConverter x:Key=""ToolTipConverter"" />
</Grid.Resources>
<Grid Style=""{{StaticResource GridFillCell}}"" ToolTipService.ToolTip=""{{Binding {2}}}"">
<!--DB color-->
<Rectangle RenderTransformOrigin=""0.5,1"">
<Rectangle.Fill>
<LinearGradientBrush>
<GradientStop Color=""{{Binding Converter={{StaticResource CellConverter}}, ConverterParameter='a{1}'}}"" Offset=""0"" />
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.RenderTransform>
<CompositeTransform ScaleY=""1"" />
</Rectangle.RenderTransform>
</Rectangle>
<!--Main Color-->
<Rectangle RenderTransformOrigin=""0.5,1"">
<Rectangle.Fill>
<LinearGradientBrush>
<GradientStop Color=""{{Binding Converter={{StaticResource CellConverter}}, ConverterParameter='{1}'}}"" Offset=""0"" />
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.RenderTransform>
<CompositeTransform ScaleY=""{{Binding Converter={{StaticResource CellScaleConverter}}, ConverterParameter='{1}'}}"" />
</Rectangle.RenderTransform>
</Rectangle>
<!--Gradient color-->
<Rectangle RenderTransformOrigin=""0.5,1"">
<Rectangle.Fill>
<LinearGradientBrush EndPoint=""0,0"" StartPoint=""0,1"">
<GradientStop Offset=""1"" Color=""Transparent""/>
<GradientStop Color=""#33000000""/>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.RenderTransform>
<CompositeTransform ScaleY=""{{Binding Converter={{StaticResource CellScaleConverter}}, ConverterParameter='{1}'}}"" />
</Rectangle.RenderTransform>
</Rectangle>
<!--Text-->
<TextBlock Style=""{{StaticResource WBColumnNumberTextBlock}}"" Text=""{{Binding {0}, StringFormat=N2}}"" FontSize=""10""/>
</Grid>
</Grid>
</DataTemplate>";
#endregion
#region
private static readonly string HoursNotAllocedCellTemplate = @"<DataTemplate
xmlns=""http://schemas.microsoft.com/client/2007""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:converter=""clr-namespace:WorkBook.Client.Converter;assembly=WorkBook.Client"">
<Grid>
<Grid.Resources>
<converter:BackGroundConverter x:Key=""BackGroundConverter"" />
</Grid.Resources>
<Grid Style=""{{StaticResource GridFillCell}}"">
<TextBlock Style=""{{StaticResource WBColumnNumberTextBlock}}"" Text=""{{Binding {0}, StringFormat=N2}}"" FontSize=""10""/>
</Grid>
</Grid>
</DataTemplate>";
#endregion
#region
private static readonly string TotalCellTemplate = @"<DataTemplate
xmlns=""http://schemas.microsoft.com/client/2007""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:converter=""clr-namespace:WorkBook.Client.Converter;assembly=WorkBook.Client""
xmlns:local=""clr-namespace:WorkBook.Client.Views.Scheduling;assembly=WorkBook.Client"">
<Grid>
<Grid.Resources>
<converter:BackGroundConverter x:Key=""BackGroundConverter"" />
<local:CellConverter x:Key=""CellConverter"" />
<local:CellScaleConverter x:Key=""CellScaleConverter"" />
</Grid.Resources>
<Grid Style=""{{StaticResource GridFillCell}}"">
<!--Color-->
<Rectangle RenderTransformOrigin=""0.5,1"">
<Rectangle.Fill>
<LinearGradientBrush>
<GradientStop Color=""{{Binding Converter={{StaticResource CellConverter}}, ConverterParameter='Total'}}"" Offset=""0"" />
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.RenderTransform>
<CompositeTransform ScaleY=""{{Binding Converter={{StaticResource CellScaleConverter}}, ConverterParameter='Total'}}"" />
</Rectangle.RenderTransform>
</Rectangle>
<!--Gradient color-->
<Rectangle RenderTransformOrigin=""0.5,1"">
<Rectangle.Fill>
<LinearGradientBrush EndPoint=""0,0"" StartPoint=""0,1"">
<GradientStop Offset=""1"" Color=""Transparent""/>
<GradientStop Color=""#33000000""/>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.RenderTransform>
<CompositeTransform ScaleY=""{{Binding Converter={{StaticResource CellScaleConverter}}, ConverterParameter='Total'}}"" />
</Rectangle.RenderTransform>
</Rectangle>
<!--Text-->
<TextBlock Style=""{{StaticResource WBColumnNumberTextBlock}}"" Text=""{{Binding {0}, StringFormat=N2}}"" FontSize=""10""/>
</Grid>
</Grid>
</DataTemplate>";
#endregion
Årsagen til at jeg har det i en XamlLoader er fordi det er kolonner til et datagrid som bliver lavet dynamisk.
Jeg har 2 Converter på, hvor CellScaleConverter enten returnere et tal mellem 0.0 til 1.0 eller 1, aldrig null. Den anden CellConverter returnere en farve kode som f.eks. #0000FF, heller ikke null på noget tidspunkt.
Nogen der kan gennemskue hvor fejlen evt. kan være placeret henne?