I have a ListBox
which contains a couple of TextBlock
s, an Image, and at least 2 TextBox
s. However my problem is that I need to be able to retrieve all the TextBox
(s) in the ListBox
; APART FROM THE FIRST ONE, and then assign them to a List
in C#.
Here is the ListBox in .xaml:
<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>
The ListBox may have more TextBox
s than shown in .xaml, as the user can create more by tapping on the Image
.
Thank alot, all help is appreciated.
You can do it very simply using Linq. Following sentence returns all the elements from the
ListBox
of typeTextBox
except the first one:Remember you have to add
using System.Linq;
to your file.