Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - ItemControl broken?

 
 
Old 03-14-2006   #1 (permalink)
Fil Mackay


 
 

ItemControl broken?

When I run the following XAML, I get:

- An exception; or
- A infinite loop (100% CPU, no workingset delta)

<ItemsControl Grid.Row="2" Margin="5,5,5,5"
ItemsSource="{Binding Path=Attributes}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel> ***
<Rectangle Height="100" Width="20" Fill="Red" />
</StackPanel>
etc.

Here is the wierd part: if I remove the <StackPanel> ***, it works fine.

Any thoughts?


My System SpecsSystem Spec
Old 03-14-2006   #2 (permalink)
Fil Mackay


 
 

RE: ItemControl broken?

One thing I forgot to mention, is that XAMLPad runs it fine - works, no
exceptions of CPU saturation.

Wierd huh.

--
Regards, Fil.

My System SpecsSystem Spec
Old 03-15-2006   #3 (permalink)
Fil Mackay


 
 

RE: ItemControl broken?

OK, here is the really wierd part. This version works fine:

<ItemsControl Grid.Row="2" Margin="5,0,5,5"
ItemsSource="{Binding Path=Attributes}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

... but if "<Grid/>" gets split out into "<Grid><Grid/>" then it breaks. For
the record, under VS2005 there is an exception thrown: "Object reference not
set to an instance of an object." at -

public static void Main() {

System.Threading.Thread.CurrentThread.SetApartmentState(System.Threading.ApartmentState.STA);
XmlViewer2.MyApp app = new XmlViewer2.MyApp();
app.InitializeComponent();
app.Run(); // <== exception thrown here
}

... not very helpful.

All forms work under XAMLPad, but they dont under EID - due to other
necessary parts of the XAML that the designer can't handle at this stage.

My System SpecsSystem Spec
Old 03-15-2006   #4 (permalink)
Winthrop Chan


 
 

Re: ItemControl broken?

ummm... do you mean <grid></grid> and not <grid><grid/>? The latter leaves
an unclosed <grid> tag.

"Fil Mackay" <FilMackay@discussions.microsoft.com> wrote in message
news:85B11D46-30C7-4557-88D7-3046BFFA206D@microsoft.com...
> OK, here is the really wierd part. This version works fine:
>
> <ItemsControl Grid.Row="2" Margin="5,0,5,5"
> ItemsSource="{Binding Path=Attributes}">
> <ItemsControl.ItemsPanel>
> <ItemsPanelTemplate>
> <StackPanel Orientation="Vertical" />
> </ItemsPanelTemplate>
> </ItemsControl.ItemsPanel>
> <ItemsControl.ItemTemplate>
> <DataTemplate>
> <Grid/>
> </DataTemplate>
> </ItemsControl.ItemTemplate>
> </ItemsControl>
>
> .. but if "<Grid/>" gets split out into "<Grid><Grid/>" then it breaks.
> For
> the record, under VS2005 there is an exception thrown: "Object reference
> not
> set to an instance of an object." at -
>
> public static void Main() {
>
> System.Threading.Thread.CurrentThread.SetApartmentState(System.Threading.ApartmentState.STA);
> XmlViewer2.MyApp app = new XmlViewer2.MyApp();
> app.InitializeComponent();
> app.Run(); // <== exception thrown here
> }
>
> .. not very helpful.
>
> All forms work under XAMLPad, but they dont under EID - due to other
> necessary parts of the XAML that the designer can't handle at this stage.
>



My System SpecsSystem Spec
Old 03-15-2006   #5 (permalink)
Fil Mackay


 
 

Re: ItemControl broken?

"Winthrop Chan" wrote:
> ummm... do you mean <grid></grid> and not <grid><grid/>? The latter leaves
> an unclosed <grid> tag.


Errk.. um.. yes. (it did parse both times


My System SpecsSystem Spec
Old 03-15-2006   #6 (permalink)
Marcus


 
 

Re: ItemControl broken?

I had the exact same behavior while replacing the ItemsPanel on a
StackPanel...

The syntaxt thing about where the / goes is not relevant in this case
however...

In my case, I received an error indicating that the DataTemplate could
only have one child...

When I tried out of the blue to put <WrapPanel />, it started
working...

I am wondering if it could not mean that the space between <WrapPanel>
and <WrapPanel> is somehow interpretted for the ItemTemplate as a
"Children"(Children is the default content property for the Panel
classes) element while nothing is assigned to the "content" when
<WrapPanel /> notation is used

(this is a wild guess, and your opinion is welcomed)...

Marcus

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Help! I think it's broken. Vista installation & setup
broken Vista General
Lots of problems - regedit is broken, taskbar is misbehaving, audio is broken.. HELP! Vista General
ICS is Broken Vista General
IE7 and WMP Broken! Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46