-1

這很簡單,但你如何在C#中創建一個文本框?Windows Phone - C# - 如何創建一個文本框在C#

我需要將它放置在某個位置(在ListBox的最後一項之前)的列表框中。

我需要新的TextBox來包含它的文本,名稱和寬度的屬性。

這裏的代碼名爲.xaml樣品,我需要的TextBox被放置在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> 

回答

0

上面試試這個:

// 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(); 
+0

似乎並沒有工作,它給了'listBox.Items.Last());'部分出錯(我通過這種方式將listBox重命名爲相應的名稱)。 – Newbie

+0

嘗試'listBox.Items [litBox.Items.Count-1]'然後 – anderZubi

+0

不,那沒用,它取代了圖像,我添加了一個.xaml代碼的樣本,如果有幫助的話 – Newbie

相關問題