Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 369321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:54:31+00:00 2026-05-12T13:54:31+00:00

I created a user control which contains a ListView with a custom ItemsPanelTemplate. <UserControl

  • 0

I created a user control which contains a ListView with a custom ItemsPanelTemplate.

<UserControl x:Class="..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="thisUserControl">
<ListView ItemsSource="{Binding Source={StaticResource cvs}}"
          Name="mainListView">
    <ListView.GroupStyle>
        <GroupStyle>
            ...
        </GroupStyle>
    </ListView.GroupStyle>
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <cd:TimeLinePanel UnitsPerSecond="{Binding ElementName=thisUserControl,Path=DataContext.UnitsPerSecond}" Start="{Binding ElementName=thisUserControl, Path=DataContext.Start}"/>
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>

The DataContext of the UserControl has two properties Start and UnitsPerSecond. As I am using groups I cannot simply write

Start={Binding Path=.Start}

Thus I used the code above. But if I change the binding of Start to this I get an exception:

VisualTree of ItemsPanelTemplate must be a single element.

Obviously the ItemsPanelTemplate has got just a single element.

So what could be the problem? My custom panel does not create any elements. It just arranges them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:54:31+00:00Added an answer on May 12, 2026 at 1:54 pm

    You are receiving this exception probably because you are trying to add “Children” to TimeLinePanel (or you are overriding the visual tree of the panel and returning something other than 1 in “VisualChildrenCount”). Sadly, you cannot modify the “Children” property of a panel if it is created inside an ItemsControl because of an ItemsPanelTemplate. Outside of an ItemsControl, there is no problem.

    Alternatively, you can override the template of ListView to something like the following – it works in my case, and gets rid of the exception.

    <ListView.Template>
        <ControlTemplate>
            <cd:TimeLinePanel IsItemsHost="True" UnitsPerSecond="..."/>
        <ControlTemplate>
    </ListView.ItemsPanel>
    

    There is a CodeProject article (http://www.codeproject.com/KB/WPF/ConceptualChildren.aspx) which gives some details on this behavior, which may help you understand why it is the case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a user control called 'RibbonTabX' which contains a stackpanel named 'spMain'. What
Ive created a custom UserControl that contains a single combobox. The currently selected value
I have an interesting problem. I've created a WPF UserControl which contains a button
I have created a custom style for my WPF datagrid by overriding its control
I have a UserControl which contains 4 ToggleButtons and I'd like to trigger a
My colleagues have create a website and there is a webpage which contains a
I have a UITableView with cells that contain a UISwitch control. It's similar to
I am used to working with ASP.NET FORMS and I am having a hard
I've been digging around Google trying to find the appropriate way to determine the
I've started a new job this week and am trying to get my head

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.