Note that there are some explanatory texts on larger screens.

plurals
  1. POFind the index of the List items - WP7
    primarykey
    data
    text
    <p>I have listbox which contains buttons listed vertically with related datas as given below;</p> <pre><code>&lt;ListBox Name="CTransactionList" Margin="0,0,0,0" &gt; &lt;ListBox.ItemTemplate &gt; &lt;DataTemplate&gt; &lt;Button Width="400" Height="200" Background="#6A040B2E" Click="completetransact"&gt; &lt;Button.Content &gt; &lt;StackPanel Orientation="Horizontal" Height="200" Width="400"&gt; &lt;Image Source="{Binding Type1}" Width="80" Height="80" VerticalAlignment="Top" Margin="0,40,0,0"/&gt; &lt;StackPanel Orientation="Vertical" Height="200"&gt; &lt;StackPanel Orientation="Horizontal" Height="30"&gt; &lt;TextBlock Width="100" FontSize="22" Text="Name:" Height="30"/&gt; &lt;TextBlock Width="200" FontSize="22" Text="{Binding Date1}" Height="30"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="30"&gt; &lt;TextBlock Width="100" FontSize="22" Text="Difficulty:" Height="30"/&gt; &lt;TextBlock Width="200" FontSize="22" Text="{Binding Amount1}" Height="30"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="30"&gt; &lt;TextBlock Width="110" FontSize="22" Text="TotalTime:" Height="30"/&gt; &lt;TextBlock Width="200" FontSize="22" Text="{Binding Time1}" Height="30"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="30"&gt; &lt;TextBlock Width="100" FontSize="22" Text="Distance:" Height="30"/&gt; &lt;TextBlock Width="200" FontSize="22" Text="{Binding Dis1}" Height="30"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="65"&gt; &lt;TextBlock Width="290" FontSize="14" Text="{Binding Def1}" Height="65" TextWrapping="Wrap" FontStyle="Italic"/&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/Button.Content&gt; &lt;/Button&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>And I'm binding the data with such classes;</p> <pre><code>[DataContract] public class CTransaction { [DataMember] public String Date1 { get; set; } [DataMember] public String Amount1 { get; set; } [DataMember] public String Type1 { get; set; } [DataMember] public String Time1 { get; set; } [DataMember] public String Dis1 { get; set; } [DataMember] public String Def1 { get; set; } [DataMember] public String Cdate1 { get; set; } [DataMember] public String Strpt1 { get; set; } [DataMember] public String Endpt1 { get; set; } [DataMember] public int Index1 { get; set; } public CTransaction(String date1, String amount1, String type1, String time1, String dis1, String def1, String cdate1, String strpt1, String endpt1,int index1) { this.Date1 = date1; this.Amount1 = amount1; this.Time1 = time1; this.Dis1 = dis1; this.Def1 = def1; this.Cdate1 = cdate1; this.Strpt1 = strpt1; this.Endpt1 = endpt1; this.Index1 = index1; switch (type1) { case "FR": this.Type1 = "Images/a.png"; break; case "TA": this.Type1 = "Images/b.png"; break; case "DA": this.Type1 = "Images/c.png"; break; case "CC": this.Type1 = "Images/mount.png"; break; } } } </code></pre> <p>As shown above, I have a data binding named Index1 which indexes the button with an arbitrary integer. I want to remove a specified indexed button by user with this code;</p> <pre><code>ctransactionList.RemoveAt("index comes here"); </code></pre> <p>My exact desire is to remove the clicked button,(i.e. if the second button clicked, then remove the second one). And I tried to embed some indexes(i.e. Index1) in it to remove it, I couldn't find any possible way; I also failed again.</p> <p>This is the way I tried;</p> <p>The removal code given above only removes the indexed item based on the whole list item count. I mean, for example, the first element always has the '0' index. It does not care my Index1 data.(I can retrieve the Index1 data with selectedButton as sender method) I wish I could have removed the button which includes the user-specified Index1 data.</p> <p>How can I do this?</p> <p>Thanks in advance. (Windows Phone 7)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload