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

  • SEARCH
  • Home
  • 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 6170319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:00:49+00:00 2026-05-23T23:00:49+00:00

I have a custom user control in XAML that creates a ItemsControl which ItemsPanel

  • 0

I have a custom user control in XAML that creates a ItemsControl which ItemsPanel is a 15 * 15 uniform grid. The ItemsControl is then populated with Cells on startup.

<UserControl x:Class="Words.GameBoard"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:Words="clr-namespace:Words"
         xmlns:Cell="Words.CellCollection"
         xmlns:CellTile="Words.Cell"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
    <Words:CellCollection x:Key="CellCollectionData">
    </Words:CellCollection>
    <Style TargetType="ItemsControl">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <UniformGrid IsItemsHost="True" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Words:Cell>
                    </Words:Cell>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>
<ItemsControl Name="BoardControl">
</ItemsControl>

The control is added to the MainWindow like this

            <clr:GameBoard>
            </clr:GameBoard>

How do i bind the Items of a ItemsControl to a Array? I don’t need Observables and stuff, I just want the Items to refresh when I click a button. Is this possible? I’ve very new to both C# and XAML

Thanks

  • 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-23T23:00:50+00:00Added an answer on May 23, 2026 at 11:00 pm

    You need to set the ItemsSource on your ItemsControl to bind the array like this:

    <ItemsControl Name="BoardControl" ItemsSource={DynamicResource CellCollectionData} />
    

    I am assuming you wanted the CellCollectionData bound. Typically, however, I would expect the data to be in the DataContext, in which case you would use:

    <ItemsControl Name="BoardControl" ItemsSource={Binding} />
    

    (if the UserControl’s DataContext was set to the array)

    or

    <ItemsControl Name="BoardControl" ItemsSource={Binding MyArray} />
    

    (if the UserControl’s DataContext was a class that contained a property that returned the array)

    While you are learning and testing, I would suggest converting the ItemsControl to a ListBox, so you can see that items are actually added (by clicking on a selectable item). Once you get the look right, you can change it back to an ItemsControl (which doesn’t allow selecting an item).

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

Sidebar

Related Questions

i have created a custom user control which im using on my main xaml
I have a custom user control that contains asp:ValidationSummary . It is placed on
I have a custom WPF user control called a TimeoutPanel that I am trying
I have a custom control with that test-code. Then I put my control on
I have an ObservableCollection that is created in user control that contains a custom
I have a custom user control with a textbox on it and I'd like
I have a custom validation function in JavaScript in a user control on a
I have a custom WinForms control (inherits from control, i.e. without user interface jsut
I have a number of application settings (in user scope) for my custom grid
I have a dependency property (Foreground) on a custom control which is inheriting from

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.