MrJul

Hello, I have a strange problem with Cider.

First, I created a simple OutlinedText control, allowing to create outlined text (based on the sample which can be found on MSDN) in a Project.Controls assembly. Then, I added a reference to controls to my Project.Client and wrote the following code, which compiles and runs fine. Editing this code within cider XAML editor, with Design pane hidden, cause no problem.

However, if I choose to show the Design pane, I got the following error on the <k: Outlined> line : "Error 1 Value 'Morpheus' cannot be assigned to property 'FontFamily'. Cannot set a property on object '' because it is in a read-only state.". Of course Cider wants me to solve the problem before being able to show the designer.

Note that if I remove the FontFamily parameter, the error switches to FontSize, then FontWeight, etc...
If I switch the Text parameter from a template binding to a constant value, the error disappears. I am really confused and can't seem to find the real origin of the problem (since the code compiles and runs without any error).

Code Snippet

<Window x:Class="Project.Client.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:k="clr-namespace:Project.Controls;assembly=Project.Controls"
Title="MainWindow" Width="800" Height="600">

<Window.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Width" Value="249" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Image Source="Images/Tab.png" Width="249" Height="30" x:Name="PART_Image" IsHitTestVisible="False" />
<Path Stroke="Black" Fill="Transparent" StrokeThickness="0" Data="M 225,0 Q 226,12 248,29 L 0,29 L 0,0 L 225,0" IsHitTestVisible="True" />
<k:OutlinedText Text="{TemplateBinding Header}" FontFamily="Morpheus" FontSize="17" FontWeight="Bold" Fill="White" Stroke="Gold" StrokeThickness="0.3" Margin="15,0,0,0" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="PART_Image" Property="Source" Value="Images/TabSelected.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>


<Grid>

<TabControl x:Name="MainTabs">
<TabItem Header="Foo" />
<TabItem Header="Bar" Margin="-50,0,0,0" />
<TabItem Header="Third" Margin="-100,0,0,0" />
</TabControl>
</Grid>

</Window>



Thanks for your help,

--
Julien


Re: Visual Studio WPF Designer Cannot set a property on object '' because it is in a read-only state.

Jim Nakashima - MSFT

Can you provide a pointer to the sample you are referring to I would like to try to reproduce this on my side.

Thanks,