Domanda

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>
È stato utile?

Soluzione

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();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top