![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is it possible to include XAML files into another XAML file? | star-italia | .NET General | 6 | 06-12-2008 04:56 AM |
| Serialization to XAML and registered names do not work | Ralf Ziller | Avalon | 0 | 08-26-2007 09:02 AM |
| IAddChild and XAML serialization process ?? | azerty | Avalon | 0 | 12-05-2006 04:04 PM |
| How to deploy an XAML-based App with its XAML-UI-File? | Solveigh | Avalon | 11 | 11-08-2006 07:50 AM |
| Serialization to XAML and cloning... | damien morton | Avalon | 0 | 03-03-2006 10:26 PM |