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 6469633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:00:58+00:00 2026-05-25T06:00:58+00:00

I’ve got a bit of a design issue here. I’ve got a view: <ItemsControl

  • 0

I’ve got a bit of a design issue here.

I’ve got a view:

<ItemsControl x:Name="CellVMs">
    <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
            <Grid />
         </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemContainerStyle>
      <Style>
        <Setter Property="Grid.Row"
                Value="{Binding Position.Y}" />
        <Setter Property="Grid.Column"
                Value="{Binding Position.X}" />
      </Style>
    </ItemsControl.ItemContainerStyle>
  </ItemsControl>

which is bound to a collection of viewmodels, that have a position property which the style there uses to position it on the ItemPanelTemplate. (Only one viewmodel per cell, and the grid cells are fixed size)

1) I would like that Grid to be pseudo-infinite, ie as EditorVMs get added and subtracted, the Grid should dynamically add and delete Row\Col Definitions, and there should always be enough Grid, and there should always be enough to fill the parent view.

2) In my containing viewmodel, I import an IGridEditor implementation instance which has a Grid property. How can I bind the ItemsPanelTemplateGrid to the IEditor.Grid?

Right now, I add the CellVM’s to a collection in the IGridEditor’s methods, then when the containing vm imports the instance, sets the containing vm’s CellVM collection to the instances collection, and the item control binds to that using Caliburn.Micro’s conventions.

I’m using Caliburn.Micro\MEF btw.

Can anyone help me figure this out?

Edit:

Been trying to understand this, but I’m coming up empty.

Only thing I can find is

<ItemsControl.ItemsPanel>
         <ItemsPanelTemplate>
            <Grid x:Name="EditorGrid"/>
         </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

and in my viemodel:

[Import("EditorGrid", typeof(Grid))]
public Grid EditorGrid { get; set; }

and a corresponding Export in class that has the methods to add things to the grid/

  • 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-25T06:00:58+00:00Added an answer on May 25, 2026 at 6:00 am

    1) I would like that Grid to be pseudo-infinite, ie as EditorVMs get
    added and subtracted, the Grid should dynamically add and delete
    Row\Col Definitions, and there should always be enough Grid, and there
    should always be enough to fill the parent view.

    You could create a custom Grid that automatically adds rows or columns as needed:

    public class AutoExpandGrid : Grid
    {
        protected override System.Windows.Media.Visual GetVisualChild(int index)
        {
            var visualChild = base.GetVisualChild(index);
    
            var uiElement = visualChild as UIElement;
            if (uiElement != null)
                EnsureEnoughRowsAndColumns(uiElement);
    
            return visualChild;
        }
    
        private void EnsureEnoughRowsAndColumns(UIElement child)
        {
            int minRows = GetRow(child) + GetRowSpan(child);
            int minColumns = GetColumn(child) + GetColumnSpan(child);
    
            while (minRows > RowDefinitions.Count)
            {
                RowDefinitions.Add(new RowDefinition());
            }
    
            while (minColumns > ColumnDefinitions.Count)
            {
                ColumnDefinitions.Add(new ColumnDefinition());
            }
        }
    }
    

    (not sure GetVisualChild is the best place to do this, but it’s the best I could find)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.