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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:14:52+00:00 2026-05-17T02:14:52+00:00

hey there i am having problem i have List<List<memoryCard>> that i want to show

  • 0

hey there
i am having problem i have

   List<List<memoryCard>> 

that i want to show in my xmal in a button how can I bind my button to the data i want thos is my usercontrol :

<

    <ControlTemplate x:Key="ButtonControlTemplate1" TargetType="{x:Type Button}">
    <Grid>
  <!--i think this is the place where i make mistake :-->
            <TextBlock Text="{Binding Path=CardWasfounded}"/>
            <Rectangle Margin="4,5,8,2" Stroke="Black" RadiusX="45" RadiusY="45" StrokeThickness="3"/>
    </Grid>
    </ControlTemplate>

    <DataTemplate x:Key="DataTemplate_Level2">
        <Button Content="{Binding}" Height="40" Width="50" Margin="4,4,4,4"  Template="{DynamicResource ButtonControlTemplate1}"/>
    </DataTemplate>

<DataTemplate x:Key="DataTemplate_Level1">
    <ItemsControl ItemsSource="{Binding }" ItemTemplate="{DynamicResource DataTemplate_Level2}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ItemsControl>
</DataTemplate>

I want every button to have binding to this memory card

 class memoryCard : INotifyPropertyChanged
{
    #region c'tor
    public memoryCard(Brush _buttonColor)
    {
        buttonColor=_buttonColor;
    }
    #endregion

    #region allReadyFoundedCard

    bool cardWasfounded = false;
        public bool CardWasfounded
        {
            get
            {
                return cardWasfounded;
            }
            set
            {
                if (cardWasfounded != value)
                {
                    cardWasfounded = value;
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this,
                        new PropertyChangedEventArgs("cardWasfounded"));

                    }
                }
            }
        }
        #endregion 

    #region colorofbutton
        string name = "sdasdas";
        public Brush buttonColor;
        public Brush ButtonColor
        {
            get
            {
                return buttonColor;
            }
            set
            {
                if (buttonColor != value)
                {
                    buttonColor = value;
                    if (PropertyChanged != null) PropertyChanged(this,
                        new PropertyChangedEventArgs("buttonColor"));
                }
            }
        }
        #endregion

    #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion
}

whom i want to bind to one of my grids this way :

using this mainwindow class:

 public MainWindow()
    {
        List<List<memoryCard>> lsts = new List<List<memoryCard>>();

        for (int i = 0; i < 5; i++)
        {
            lsts.Add(new List<memoryCard>());

            for (int j = 0; j < 5; j++)
            {
                lsts[i].Add(new memoryCard(Brushes.Green));
            }
        }

        InitializeComponent();

        lst.ItemsSource = lsts; 
    }
  • 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-17T02:14:53+00:00Added an answer on May 17, 2026 at 2:14 am

    Alright, so from what i’ve gathered you’ve got a collection of collections of a custom data type which contains a colour that you’d like to bind to.

    So heres a small demo that you should (hopefully) be able to expand.

    XAML:

    <ItemsControl ItemsSource="{Binding Path=MyCollection}" 
                  Height="300" Width="600">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Expander Header="Open Me">
                    <ItemsControl DataContext="{Binding}" ItemsSource="{Binding}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button DataContext="{Binding}"
                                        Background="{Binding Path=ButtonColor}"
                                        Content="{Binding Path=CardWasFounded}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Expander>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    

    And in the code behind:

    public ObservableCollection<List<memoryCard>> MyCollection {get; set;}
    
    public MainWindow()
    {
        DataContext = this;
        MyCollection = new ObservableCollection<List<memoryCard>>();
    
        for (int i = 0; i < 5; i++)
        {
            List<memoryCard> list = new List<memoryCard>();
    
            for (int j = 0; j < 5; j++)
            {
                list.Add(new memoryCard(Brushes.Green));
            }
            MyCollection.Add(list);
        }
    
        InitializeComponent();
    }
    

    Is this similar to what you’re trying to do?

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

Sidebar

Related Questions

hey there, i have a div that expands when the page is loaded, now
Hey guys. I have a method that gets called each second which I want
Hey im having a problem. I want to use an arrayList to make a
Hey Folks am seemingly having problems with .htaccess files. The problem: I have a
hey there, Im having problems displaying my results in this program but the program
Hey there, I am trying to get my signout button to work. This is
Hey there. I'm trying to write a small program that will read the four
Hey there I have just started Java for a course I will be taking
I want to represent the list hi, hello, goodbye, good day, howdy (with that
Hey, I am having a problem deserializing base64 json back into the .net object

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.