• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

bug in xaml serialization of Int32Collection


Robert Ludig

I have introduced an attached DependencyProperty
"CustomControl1.IntsProperty" of type Int32Collection. So I *should be
able to use it like this:

<Window x:Class="WPFApplication5.Window1"
Title="Window1" Height="300" Width="300" Loaded="Window1_Loaded"
<StackPanel x:Name="MyPanel">
<Button y:CustomControl1.Ints="2 3 5">eins</Button>
<Button y:CustomControl1.Ints="2,3,5">zwei</Button>
<Button y:CustomControl1.Ints="2,3">drei</Button>
<Button y:CustomControl1.Ints="2 3">vier</Button>
<Button y:CustomControl1.Ints="2 ">fnf</Button>
<Button y:CustomControl1.Ints="2">sechs</Button>

I defined the property inside CustomControl1 like this:

Code Snippet
#region Ints

public static void SetInts(UIElement element, Int32Collection value)
element.SetValue(IntsProperty, value);
public static Int32Collection GetInts(UIElement element)
return (Int32Collection)element.GetValue(IntsProperty);
public Int32Collection Ints
get { return (Int32Collection)GetValue(IntsProperty); }
set { SetValue(IntsProperty, value); }
public static readonly DependencyProperty IntsProperty =
DependencyProperty.RegisterAttached("Ints", typeof(Int32Collection),
new FrameworkPropertyMetadata(new Int32Collection(0),
FrameworkPropertyMetadataOptions.AffectsMeasure |
#endregion Ints

And I query the values in Window.Loaded eventhander like this:

public void Window1_Loaded(object sender, RoutedEventArgs args)
foreach (DependencyObject depObj
in LogicalTreeHelper.GetChildren(this.MyPanel))
Int32Collection ints =
Console.WriteLine(depObj.ToString() + " " + ints.ToString());
It seems as if the Int32CollectionValueSerializer is not doing his job
and the values it did not get deserialized from XAML/string correctly.
Only the the values "2 3 5" and the values "2,3,5" can be found. The
rest of the Int32Collections where the values in xaml have been "2,3"
"2 3" "2" and "2 " are empty.

Another very intersting phenomenon is that the designer of visual
studio Orcas Beta 1 (wich I used for this example) acutually gets it
right ! When the Designer creates and shows the wpf window embedded
in visual studio all 6 buttons have the correct values.

How come this happens? And what can I do against that? Is this a bug
in visual studio orcas ? I hope it is not abug in .NET 3.0

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)