-1

It's pretty simple, but how do you create a TextBox in C#?

I need to place it within a ListBox at a certain location (before the last item of the ListBox).

I need the new TextBox to contain properties about it's Text, Name, and Width.

Here's the sample of code in .xaml, I need the TextBox to be placed above the Image

<ListBox Margin="0,-20,0,0" Height="548" Name="listBoxNew">
    <TextBlock Name="textBlockName" Text="Name"/>
    <TextBox Name="textBoxName" Width="420" Margin="-12,0,0,0"/>
    <TextBlock Name="textBlockAdd" Text="Add" Margin="0,10,0,0"/>
    <TextBox Name="textBoxAdd" Width="420" Margin="-12,0,0,0"/>
    <Image Name="imageAdd" Source="/SecondApp%2b;component/Images/buttonAdd1.png" Height="50" Margin="0,5,0,0" Tap="imageAdd_Tap" toolkit:TiltEffect.IsTiltEnabled="True" ManipulationStarted="imageAddExersize_ManipulationStarted" ManipulationCompleted="imageAddExersize_ManipulationCompleted" />
</ListBox>
Newbie
  • 1,160
  • 2
  • 11
  • 24

1 Answers1

0

Try this:

    // Add the last item to the listbox again
    listBox.Items.Add(listBox.Items.Last());

    // Place the textbox in the previous item
    listBox.Items[listBox.Items.Count - 2] = new TextBox();
anderZubi
  • 6,414
  • 5
  • 37
  • 67
  • That didn't seem to work, it brought up an error at the `listBox.Items.Last());` section (I renamed listBox to the appropriate name by the way). – Newbie Jul 19 '13 at 16:13
  • try `listBox.Items[litBox.Items.Count-1]` then – anderZubi Jul 19 '13 at 16:16
  • No, that didn't work, it replaced the Image, I added a sample of .xaml code if that helps – Newbie Jul 19 '13 at 16:21
  • Also this procedure needs to be able to be recursive, the event that triggers the procedure is attached to the image. – Newbie Jul 19 '13 at 16:56