![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | bug in xaml serialization of Int32Collection 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" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" Loaded="Window1_Loaded" xmlns:y="clr-namespace:WPFApplication5"> <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> </StackPanel> </Window> 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), typeof(CustomControl1), new FrameworkPropertyMetadata(new Int32Collection(0), FrameworkPropertyMetadataOptions.AffectsMeasure | 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 = (Int32Collection)depObj.GetValue(CustomControl1.IntsProperty); 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 System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Is it possible to include XAML files into another XAML file? | .NET General | |||