Windows Vista Forums

ItemControl broken?
  1. #1


    Fil Mackay Guest

    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

  2. #2


    Fil Mackay Guest

    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

  3. #3


    Fil Mackay Guest

    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

  4. #4


    Winthrop Chan Guest

    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

  5. #5


    Fil Mackay Guest

    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

  6. #6


    Marcus Guest

    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

ItemControl broken? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Alt-tab is broken freeman General Discussion 1 07 Jan 2010
Help! I think it's broken. Kzxke Vista installation & setup 0 25 Feb 2009
Lots of problems - regedit is broken, taskbar is misbehaving, audio is broken.. HELP! Elspeth Vista General 3 02 Jul 2008
SP1 seems to have broken WMP 11 David Vista General 19 27 May 2008
ICS is Broken Brad Vista General 1 26 Mar 2008