locked
Expression Blend C# Array, Variable, Tipe What is the structure to use RRS feed

  • Question

  • I was see it declaration that don't is bad.

    ArraySegment<Button> indexButton;

    Bat I do not want what is use for initialization and accees it. I use 32 Button and want to declare in Table Variable for acces index of Variable name.  I create a game with 32 Button http://nituleac.idilis.ro/Septica.html bat all the acces Button is individuals name or dopio name - Button temp; temp=Button1; for acces at them. I need Table Array [1..32] of Button temp for example, and I don't know

    Please respond me in English Italian Romana.
    Thursday, November 12, 2009 1:26 AM

Answers

  • I'll do my best to answer your question.  It sounds like you want to simplify the creation and handling of a large number (32) of buttons in your GUI.  Personally, I'd do this entire thing in code behind.  That way, you don't have to deal with the layout graphically.

    Anyhow, I think there are a couple of ways you can handle this.  First, do you want to put every button in a layout container?  If you use something like a StackPanel (e.g. called mystackpanel), you will add each new button into mystackpanel.Children.  Children is a UIElementCollection that is indexed like an array or list.

    You could also create a List<Button> and add a reference to each button into this collection as you add them into the stackpanel, in case you don't want to use a stackpanel to create the buttons in your project.

    Here's a link to my proposed solution.  Please download it and run it, and let me know if this helps.


    Dave

    • Marked as answer by Nituleac Mihai Sunday, November 15, 2009 3:32 PM
    Friday, November 13, 2009 6:44 PM

All replies

  • I'll do my best to answer your question.  It sounds like you want to simplify the creation and handling of a large number (32) of buttons in your GUI.  Personally, I'd do this entire thing in code behind.  That way, you don't have to deal with the layout graphically.

    Anyhow, I think there are a couple of ways you can handle this.  First, do you want to put every button in a layout container?  If you use something like a StackPanel (e.g. called mystackpanel), you will add each new button into mystackpanel.Children.  Children is a UIElementCollection that is indexed like an array or list.

    You could also create a List<Button> and add a reference to each button into this collection as you add them into the stackpanel, in case you don't want to use a stackpanel to create the buttons in your project.

    Here's a link to my proposed solution.  Please download it and run it, and let me know if this helps.


    Dave

    • Marked as answer by Nituleac Mihai Sunday, November 15, 2009 3:32 PM
    Friday, November 13, 2009 6:44 PM
  • It is a good ideea, bat non is true for my aplication. I am in xaml declared with a various foto that 32 Buttons. I want to use List<Button> temp, bat I don't know sintax. I don't want a stackpanell. I need help temp[1]=Button1;temp[2]=Button2.... and at end. Use Canvas.SetLeft(temp[i],double). I don't know sintax per initialize temp[x]=Butonx. I see the essample and try con List . In genre Button1 non is a variabile, bat I use b1=button1; b2=button2; in fine temp=b1; b1=b2; b2=temp; comme change il object. bat I need help initialized and use b[i] for un svilupatore good.

    Line 47

    List<Button> temp;

    Error: Imposible trovare il tipo o il nome dello spazio dei nomi "List"; probabilmente manca una directiva using o un riferimento a un assembly
    Error: Non exists type or name in list of name "List"; it is possible non exist it directtive using or the riferiment as un assembly

    It's ok.
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Data;
    using System.Windows.Media.Imaging;

    List
    Friday, November 13, 2009 10:29 PM
  • I was see it declaration that don't is bad.

    ArraySegment<Button> indexButton;

    Bat I do not want what is use for initialization and accees it. I use 32 Button and want to declare in Table Variable for acces index of Variable name.  I create a game with 32 Button http://nituleac.idilis.ro/Septica.html bat all the acces Button is individuals name or dopio name - Button temp; temp=Button1; for acces at them. I need Table Array [1..32] of Button temp for example, and I don't know

    Please respond me in English Italian Romana.
    at last my message I write Button and I dont close the tag Button. This page-site are error. at editing
    Sunday, November 15, 2009 3:19 AM