Listview does not contain a definition for selecteditemsWhat does the [Flags] Enum Attribute mean in C#?The located assembly's manifest definition does not match the assembly referenceCase insensitive 'Contains(string)'Lazy load of images in ListViewDoes C# have extension properties?How do I remove lines between ListViews on Android?Background ListView becomes black when scrollingDynamically add elements to a listView AndroidAndroid ListView with different layouts for each rowXamarin.Forms Listview with rotated labels
Sloth and the Hindrances
Leaving the USA for 10 yrs when you have asylum
Tikzcd in beamer not working
Why has M1 grown a lot faster than M3 after the financial crisis?
Is a MySQL database a viable alternative to LDAP?
Are personality traits, ideals, bonds, and flaws required?
How to find a reviewer/editor for my paper?
How do I politely hint customers to leave my store, without pretending to need leave store myself?
Does the 2019 UA artificer need to prepare the Lesser Restoration spell to cast it with their Alchemical Mastery feature?
Are programming languages necessary/useful for operations research practitioner?
Do you need to burn fuel between gravity assists?
A PEMDAS issue request for explanation
Why would an airport be depicted with symbology for runways longer than 8,069 feet even though it is reported on the sectional as 7,200 feet?
Can you mark a new target with the Hunter's Mark spell if the original target shifts to a different plane?
When calculating averages, why can we treat exploding die as if they're independent?
Was Robin Hood's point of view ethically sound?
What is the name/purpose of this component?
Isn't that (two voices leaping to C like this) a breaking of the rules of four-part harmony?
Methods and Feasibility of Antimatter Mining?
How should we understand "unobscured by flying friends" in this context?
Why do the British opposition parties not want a new election?
Milankovitch Cycle induced climate change
If you draw two cards in consecutively in a standard deck of 52 cards, what is the probability of getting black on the second draw?
Chandrayaan 2: Why is Vikram Lander's life limited to 14 Days?
Listview does not contain a definition for selecteditems
What does the [Flags] Enum Attribute mean in C#?The located assembly's manifest definition does not match the assembly referenceCase insensitive 'Contains(string)'Lazy load of images in ListViewDoes C# have extension properties?How do I remove lines between ListViews on Android?Background ListView becomes black when scrollingDynamically add elements to a listView AndroidAndroid ListView with different layouts for each rowXamarin.Forms Listview with rotated labels
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using Xamarin.Forms.I want to remove the selected item in listview after clicking Remove button.
My xaml
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Item ID" Margin="25,10,4,4" FontSize="Small" TextColor="Black" />
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Name" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
My cs code
private void reject(object sender, EventArgs args)
foreach (var v in ProductsListView.SelectedItems)
ProductsListView.ItemSelected.Remove(v);
DisplayAlert("Rejected","Request Rejected!!", "OK");
I am getting this error:
listview does not contain a definition for selecteditem, ItemSelected
c# listview xamarin.forms
add a comment |
I am using Xamarin.Forms.I want to remove the selected item in listview after clicking Remove button.
My xaml
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Item ID" Margin="25,10,4,4" FontSize="Small" TextColor="Black" />
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Name" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
My cs code
private void reject(object sender, EventArgs args)
foreach (var v in ProductsListView.SelectedItems)
ProductsListView.ItemSelected.Remove(v);
DisplayAlert("Rejected","Request Rejected!!", "OK");
I am getting this error:
listview does not contain a definition for selecteditem, ItemSelected
c# listview xamarin.forms
If your issue has been completed with answer below , you can mark as completed my answer.
– Batuhan
Mar 28 at 8:50
Can you please explain what exactly are you trying to do here?
– FreakyAli
Mar 28 at 9:27
@G.hakim i want to delete the selected data after clicking reject button.i attached the delete code in reject function.but it throws error " listview does not contain a definition for selecteditem , ItemSelected"
– Anu Priya
Mar 28 at 9:30
Can you point out the line of code where this happens
– FreakyAli
Mar 28 at 9:32
foreach (var v in ProductsListView.SelectedItems) ProductsListView.ItemSelected.Remove(v); // selectedItem and itemSelected
– Anu Priya
Mar 28 at 9:34
add a comment |
I am using Xamarin.Forms.I want to remove the selected item in listview after clicking Remove button.
My xaml
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Item ID" Margin="25,10,4,4" FontSize="Small" TextColor="Black" />
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Name" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
My cs code
private void reject(object sender, EventArgs args)
foreach (var v in ProductsListView.SelectedItems)
ProductsListView.ItemSelected.Remove(v);
DisplayAlert("Rejected","Request Rejected!!", "OK");
I am getting this error:
listview does not contain a definition for selecteditem, ItemSelected
c# listview xamarin.forms
I am using Xamarin.Forms.I want to remove the selected item in listview after clicking Remove button.
My xaml
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Item ID" Margin="25,10,4,4" FontSize="Small" TextColor="Black" />
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Name" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
My cs code
private void reject(object sender, EventArgs args)
foreach (var v in ProductsListView.SelectedItems)
ProductsListView.ItemSelected.Remove(v);
DisplayAlert("Rejected","Request Rejected!!", "OK");
I am getting this error:
listview does not contain a definition for selecteditem, ItemSelected
c# listview xamarin.forms
c# listview xamarin.forms
edited Mar 28 at 10:51
Anu Priya
asked Mar 28 at 7:26
Anu PriyaAnu Priya
105 bronze badges
105 bronze badges
If your issue has been completed with answer below , you can mark as completed my answer.
– Batuhan
Mar 28 at 8:50
Can you please explain what exactly are you trying to do here?
– FreakyAli
Mar 28 at 9:27
@G.hakim i want to delete the selected data after clicking reject button.i attached the delete code in reject function.but it throws error " listview does not contain a definition for selecteditem , ItemSelected"
– Anu Priya
Mar 28 at 9:30
Can you point out the line of code where this happens
– FreakyAli
Mar 28 at 9:32
foreach (var v in ProductsListView.SelectedItems) ProductsListView.ItemSelected.Remove(v); // selectedItem and itemSelected
– Anu Priya
Mar 28 at 9:34
add a comment |
If your issue has been completed with answer below , you can mark as completed my answer.
– Batuhan
Mar 28 at 8:50
Can you please explain what exactly are you trying to do here?
– FreakyAli
Mar 28 at 9:27
@G.hakim i want to delete the selected data after clicking reject button.i attached the delete code in reject function.but it throws error " listview does not contain a definition for selecteditem , ItemSelected"
– Anu Priya
Mar 28 at 9:30
Can you point out the line of code where this happens
– FreakyAli
Mar 28 at 9:32
foreach (var v in ProductsListView.SelectedItems) ProductsListView.ItemSelected.Remove(v); // selectedItem and itemSelected
– Anu Priya
Mar 28 at 9:34
If your issue has been completed with answer below , you can mark as completed my answer.
– Batuhan
Mar 28 at 8:50
If your issue has been completed with answer below , you can mark as completed my answer.
– Batuhan
Mar 28 at 8:50
Can you please explain what exactly are you trying to do here?
– FreakyAli
Mar 28 at 9:27
Can you please explain what exactly are you trying to do here?
– FreakyAli
Mar 28 at 9:27
@G.hakim i want to delete the selected data after clicking reject button.i attached the delete code in reject function.but it throws error " listview does not contain a definition for selecteditem , ItemSelected"
– Anu Priya
Mar 28 at 9:30
@G.hakim i want to delete the selected data after clicking reject button.i attached the delete code in reject function.but it throws error " listview does not contain a definition for selecteditem , ItemSelected"
– Anu Priya
Mar 28 at 9:30
Can you point out the line of code where this happens
– FreakyAli
Mar 28 at 9:32
Can you point out the line of code where this happens
– FreakyAli
Mar 28 at 9:32
foreach (var v in ProductsListView.SelectedItems) ProductsListView.ItemSelected.Remove(v); // selectedItem and itemSelected
– Anu Priya
Mar 28 at 9:34
foreach (var v in ProductsListView.SelectedItems) ProductsListView.ItemSelected.Remove(v); // selectedItem and itemSelected
– Anu Priya
Mar 28 at 9:34
add a comment |
2 Answers
2
active
oldest
votes
You can try cast it to ProductListView,
var selectedItems = (ListView/* or ProductListView*/)sender; //-> you need casting to access it.
And you can change list view item source
public void reject(your_list_of_model_type your_list_of_model)
your_list_of_model.RemoveRange(selectedItems);
ProductListView.ItemSource = your_list_of_model;
Solution 2 :
Here is what you could do :
This be my model class :
public class Item
public string ItemName get; set;
public string ItemDetails get; set;
And in my XAML or you can write this in code as well, bind to the Command Parameter of your Item template :
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked"></Button>
Full Item Template will be like below :
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="Binding ItemName" HorizontalOptions="StartAndExpand" FontSize="30"></Label>
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked">
</Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
And in you code file you can do this :
public void DeleteClicked(object sender, EventArgs e)
var item = (Xamarin.Forms.Button)sender;
Item listitem = (from itm in allItems
where itm.ItemName == item.CommandParameter.ToString()
select itm)
.FirstOrDefault<Item>();
allItems.Remove(listitem);
IMPORTANT : This would only delete the item from the bound collection. To delete it from the original list you need to use ObservableCollection
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
I updated my answer
– Batuhan
Mar 28 at 9:30
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
updated my answer again
– Batuhan
Mar 28 at 9:46
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
|
show 4 more comments
You can add all the toggled items to a list, suppose selectedItems
. And when you click REJECT
button, delete the selectedItems
from the datasource of listview.
The full code is like this:
MainPage.xaml:
<StackLayout Orientation="Vertical">
<!-- Place new controls here -->
<Button Text="APPROVE"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="REJECT"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="reject"/>
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
MainPage.xaml.cs:
public partial class MainPage : ContentPage
ObservableCollection<ItemModel> allItems = new ObservableCollection<ItemModel>();
List<ItemModel> selectedItems = new List<ItemModel>();
public MainPage()
InitializeComponent();
InitializeData();
ProductsListView.ItemsSource = allItems;
private void reject(object sender, EventArgs e)
foreach (var v in selectedItems)
allItems.Remove(v);
DisplayAlert("Rejected", "Request Rejected!!", "OK");
private void Switch_Toggled(object sender, ToggledEventArgs e)
var switch1 = (Switch)sender;
var item = (ItemModel)switch1.BindingContext;
var isSelected = !item.selected;
if (isSelected)
selectedItems.Add(item);
else
selectedItems.Remove(item);
private void InitializeData()
allItems.Add(new ItemModel name = "Onion Rings, Medium",
retail_modified_item_id = 1000630,
old_price = 1.29,
new_price = 9.45,
selected = false
);
allItems.Add(new ItemModel
name = "Hashbrowns",
retail_modified_item_id = 1000739,
old_price = 0.99,
new_price = 8.5,
selected = false
);
allItems.Add(new ItemModel
name = "Amstel Light, Single",
retail_modified_item_id = 1002038,
old_price = 3.5,
new_price = 18,
selected = false
);
ItemModel.cs:
class ItemModel
public string name get; set;
public int retail_modified_item_id get; set;
public double old_price get; set;
public double new_price get; set;
public bool selected get; set;
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392165%2flistview-does-not-contain-a-definition-for-selecteditems%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try cast it to ProductListView,
var selectedItems = (ListView/* or ProductListView*/)sender; //-> you need casting to access it.
And you can change list view item source
public void reject(your_list_of_model_type your_list_of_model)
your_list_of_model.RemoveRange(selectedItems);
ProductListView.ItemSource = your_list_of_model;
Solution 2 :
Here is what you could do :
This be my model class :
public class Item
public string ItemName get; set;
public string ItemDetails get; set;
And in my XAML or you can write this in code as well, bind to the Command Parameter of your Item template :
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked"></Button>
Full Item Template will be like below :
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="Binding ItemName" HorizontalOptions="StartAndExpand" FontSize="30"></Label>
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked">
</Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
And in you code file you can do this :
public void DeleteClicked(object sender, EventArgs e)
var item = (Xamarin.Forms.Button)sender;
Item listitem = (from itm in allItems
where itm.ItemName == item.CommandParameter.ToString()
select itm)
.FirstOrDefault<Item>();
allItems.Remove(listitem);
IMPORTANT : This would only delete the item from the bound collection. To delete it from the original list you need to use ObservableCollection
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
I updated my answer
– Batuhan
Mar 28 at 9:30
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
updated my answer again
– Batuhan
Mar 28 at 9:46
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
|
show 4 more comments
You can try cast it to ProductListView,
var selectedItems = (ListView/* or ProductListView*/)sender; //-> you need casting to access it.
And you can change list view item source
public void reject(your_list_of_model_type your_list_of_model)
your_list_of_model.RemoveRange(selectedItems);
ProductListView.ItemSource = your_list_of_model;
Solution 2 :
Here is what you could do :
This be my model class :
public class Item
public string ItemName get; set;
public string ItemDetails get; set;
And in my XAML or you can write this in code as well, bind to the Command Parameter of your Item template :
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked"></Button>
Full Item Template will be like below :
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="Binding ItemName" HorizontalOptions="StartAndExpand" FontSize="30"></Label>
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked">
</Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
And in you code file you can do this :
public void DeleteClicked(object sender, EventArgs e)
var item = (Xamarin.Forms.Button)sender;
Item listitem = (from itm in allItems
where itm.ItemName == item.CommandParameter.ToString()
select itm)
.FirstOrDefault<Item>();
allItems.Remove(listitem);
IMPORTANT : This would only delete the item from the bound collection. To delete it from the original list you need to use ObservableCollection
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
I updated my answer
– Batuhan
Mar 28 at 9:30
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
updated my answer again
– Batuhan
Mar 28 at 9:46
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
|
show 4 more comments
You can try cast it to ProductListView,
var selectedItems = (ListView/* or ProductListView*/)sender; //-> you need casting to access it.
And you can change list view item source
public void reject(your_list_of_model_type your_list_of_model)
your_list_of_model.RemoveRange(selectedItems);
ProductListView.ItemSource = your_list_of_model;
Solution 2 :
Here is what you could do :
This be my model class :
public class Item
public string ItemName get; set;
public string ItemDetails get; set;
And in my XAML or you can write this in code as well, bind to the Command Parameter of your Item template :
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked"></Button>
Full Item Template will be like below :
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="Binding ItemName" HorizontalOptions="StartAndExpand" FontSize="30"></Label>
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked">
</Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
And in you code file you can do this :
public void DeleteClicked(object sender, EventArgs e)
var item = (Xamarin.Forms.Button)sender;
Item listitem = (from itm in allItems
where itm.ItemName == item.CommandParameter.ToString()
select itm)
.FirstOrDefault<Item>();
allItems.Remove(listitem);
IMPORTANT : This would only delete the item from the bound collection. To delete it from the original list you need to use ObservableCollection
You can try cast it to ProductListView,
var selectedItems = (ListView/* or ProductListView*/)sender; //-> you need casting to access it.
And you can change list view item source
public void reject(your_list_of_model_type your_list_of_model)
your_list_of_model.RemoveRange(selectedItems);
ProductListView.ItemSource = your_list_of_model;
Solution 2 :
Here is what you could do :
This be my model class :
public class Item
public string ItemName get; set;
public string ItemDetails get; set;
And in my XAML or you can write this in code as well, bind to the Command Parameter of your Item template :
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked"></Button>
Full Item Template will be like below :
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="Binding ItemName" HorizontalOptions="StartAndExpand" FontSize="30"></Label>
<Button Text="Delete" CommandParameter="Binding ItemName" Clicked="DeleteClicked">
</Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
And in you code file you can do this :
public void DeleteClicked(object sender, EventArgs e)
var item = (Xamarin.Forms.Button)sender;
Item listitem = (from itm in allItems
where itm.ItemName == item.CommandParameter.ToString()
select itm)
.FirstOrDefault<Item>();
allItems.Remove(listitem);
IMPORTANT : This would only delete the item from the bound collection. To delete it from the original list you need to use ObservableCollection
edited Mar 28 at 9:56
answered Mar 28 at 7:57
BatuhanBatuhan
3923 silver badges14 bronze badges
3923 silver badges14 bronze badges
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
I updated my answer
– Batuhan
Mar 28 at 9:30
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
updated my answer again
– Batuhan
Mar 28 at 9:46
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
|
show 4 more comments
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
I updated my answer
– Batuhan
Mar 28 at 9:30
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
updated my answer again
– Batuhan
Mar 28 at 9:46
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
can you explain this code i can't understand.From this code how can i get all selected value ?
– Anu Priya
Mar 28 at 8:52
I updated my answer
– Batuhan
Mar 28 at 9:30
I updated my answer
– Batuhan
Mar 28 at 9:30
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
The type or namespace name 'ProductsListView' could not be found (are you missing a using directive or an assembly reference?) , The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= i am getting these 2 errors
– Anu Priya
Mar 28 at 9:37
updated my answer again
– Batuhan
Mar 28 at 9:46
updated my answer again
– Batuhan
Mar 28 at 9:46
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
foreach statement cannot operate on variables of type 'ListView' because 'ListView' does not contain a public instance definition for 'GetEnumerator' - foreach (var item in selectedItems ) ERROR IN SELECTEDITEMS ..... The event 'ListView.ItemSelected' can only appear on the left hand side of += or -= ERROR IN ProductsListView.ItemSelected.Remove(item); Actually why these errors are happening what mistake i did ?
– Anu Priya
Mar 28 at 9:50
|
show 4 more comments
You can add all the toggled items to a list, suppose selectedItems
. And when you click REJECT
button, delete the selectedItems
from the datasource of listview.
The full code is like this:
MainPage.xaml:
<StackLayout Orientation="Vertical">
<!-- Place new controls here -->
<Button Text="APPROVE"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="REJECT"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="reject"/>
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
MainPage.xaml.cs:
public partial class MainPage : ContentPage
ObservableCollection<ItemModel> allItems = new ObservableCollection<ItemModel>();
List<ItemModel> selectedItems = new List<ItemModel>();
public MainPage()
InitializeComponent();
InitializeData();
ProductsListView.ItemsSource = allItems;
private void reject(object sender, EventArgs e)
foreach (var v in selectedItems)
allItems.Remove(v);
DisplayAlert("Rejected", "Request Rejected!!", "OK");
private void Switch_Toggled(object sender, ToggledEventArgs e)
var switch1 = (Switch)sender;
var item = (ItemModel)switch1.BindingContext;
var isSelected = !item.selected;
if (isSelected)
selectedItems.Add(item);
else
selectedItems.Remove(item);
private void InitializeData()
allItems.Add(new ItemModel name = "Onion Rings, Medium",
retail_modified_item_id = 1000630,
old_price = 1.29,
new_price = 9.45,
selected = false
);
allItems.Add(new ItemModel
name = "Hashbrowns",
retail_modified_item_id = 1000739,
old_price = 0.99,
new_price = 8.5,
selected = false
);
allItems.Add(new ItemModel
name = "Amstel Light, Single",
retail_modified_item_id = 1002038,
old_price = 3.5,
new_price = 18,
selected = false
);
ItemModel.cs:
class ItemModel
public string name get; set;
public int retail_modified_item_id get; set;
public double old_price get; set;
public double new_price get; set;
public bool selected get; set;
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
add a comment |
You can add all the toggled items to a list, suppose selectedItems
. And when you click REJECT
button, delete the selectedItems
from the datasource of listview.
The full code is like this:
MainPage.xaml:
<StackLayout Orientation="Vertical">
<!-- Place new controls here -->
<Button Text="APPROVE"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="REJECT"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="reject"/>
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
MainPage.xaml.cs:
public partial class MainPage : ContentPage
ObservableCollection<ItemModel> allItems = new ObservableCollection<ItemModel>();
List<ItemModel> selectedItems = new List<ItemModel>();
public MainPage()
InitializeComponent();
InitializeData();
ProductsListView.ItemsSource = allItems;
private void reject(object sender, EventArgs e)
foreach (var v in selectedItems)
allItems.Remove(v);
DisplayAlert("Rejected", "Request Rejected!!", "OK");
private void Switch_Toggled(object sender, ToggledEventArgs e)
var switch1 = (Switch)sender;
var item = (ItemModel)switch1.BindingContext;
var isSelected = !item.selected;
if (isSelected)
selectedItems.Add(item);
else
selectedItems.Remove(item);
private void InitializeData()
allItems.Add(new ItemModel name = "Onion Rings, Medium",
retail_modified_item_id = 1000630,
old_price = 1.29,
new_price = 9.45,
selected = false
);
allItems.Add(new ItemModel
name = "Hashbrowns",
retail_modified_item_id = 1000739,
old_price = 0.99,
new_price = 8.5,
selected = false
);
allItems.Add(new ItemModel
name = "Amstel Light, Single",
retail_modified_item_id = 1002038,
old_price = 3.5,
new_price = 18,
selected = false
);
ItemModel.cs:
class ItemModel
public string name get; set;
public int retail_modified_item_id get; set;
public double old_price get; set;
public double new_price get; set;
public bool selected get; set;
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
add a comment |
You can add all the toggled items to a list, suppose selectedItems
. And when you click REJECT
button, delete the selectedItems
from the datasource of listview.
The full code is like this:
MainPage.xaml:
<StackLayout Orientation="Vertical">
<!-- Place new controls here -->
<Button Text="APPROVE"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="REJECT"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="reject"/>
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
MainPage.xaml.cs:
public partial class MainPage : ContentPage
ObservableCollection<ItemModel> allItems = new ObservableCollection<ItemModel>();
List<ItemModel> selectedItems = new List<ItemModel>();
public MainPage()
InitializeComponent();
InitializeData();
ProductsListView.ItemsSource = allItems;
private void reject(object sender, EventArgs e)
foreach (var v in selectedItems)
allItems.Remove(v);
DisplayAlert("Rejected", "Request Rejected!!", "OK");
private void Switch_Toggled(object sender, ToggledEventArgs e)
var switch1 = (Switch)sender;
var item = (ItemModel)switch1.BindingContext;
var isSelected = !item.selected;
if (isSelected)
selectedItems.Add(item);
else
selectedItems.Remove(item);
private void InitializeData()
allItems.Add(new ItemModel name = "Onion Rings, Medium",
retail_modified_item_id = 1000630,
old_price = 1.29,
new_price = 9.45,
selected = false
);
allItems.Add(new ItemModel
name = "Hashbrowns",
retail_modified_item_id = 1000739,
old_price = 0.99,
new_price = 8.5,
selected = false
);
allItems.Add(new ItemModel
name = "Amstel Light, Single",
retail_modified_item_id = 1002038,
old_price = 3.5,
new_price = 18,
selected = false
);
ItemModel.cs:
class ItemModel
public string name get; set;
public int retail_modified_item_id get; set;
public double old_price get; set;
public double new_price get; set;
public bool selected get; set;
You can add all the toggled items to a list, suppose selectedItems
. And when you click REJECT
button, delete the selectedItems
from the datasource of listview.
The full code is like this:
MainPage.xaml:
<StackLayout Orientation="Vertical">
<!-- Place new controls here -->
<Button Text="APPROVE"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="REJECT"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="reject"/>
<ListView x:Name="ProductsListView"
HasUnevenRows="True"
BackgroundColor="#ecf0f1"
SeparatorVisibility="None"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" Margin="6,4,6,4"
BackgroundColor="White">
<StackLayout Orientation="Horizontal">
<Label Text="Binding name" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
<Switch IsToggled="false" Margin="210,2,2,2" Toggled="Switch_Toggled" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Binding retail_modified_item_id" Margin="25,10,4,4" TextColor="Black" FontSize="12" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="OldPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small"/>
<Label Text="Binding old_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="NewPrice" Margin="25,2,8,4" TextColor="Black" FontSize="Small" />
<Label Text="Binding new_price" Margin="32,1,8,4" TextColor="Black" FontSize="Small" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
MainPage.xaml.cs:
public partial class MainPage : ContentPage
ObservableCollection<ItemModel> allItems = new ObservableCollection<ItemModel>();
List<ItemModel> selectedItems = new List<ItemModel>();
public MainPage()
InitializeComponent();
InitializeData();
ProductsListView.ItemsSource = allItems;
private void reject(object sender, EventArgs e)
foreach (var v in selectedItems)
allItems.Remove(v);
DisplayAlert("Rejected", "Request Rejected!!", "OK");
private void Switch_Toggled(object sender, ToggledEventArgs e)
var switch1 = (Switch)sender;
var item = (ItemModel)switch1.BindingContext;
var isSelected = !item.selected;
if (isSelected)
selectedItems.Add(item);
else
selectedItems.Remove(item);
private void InitializeData()
allItems.Add(new ItemModel name = "Onion Rings, Medium",
retail_modified_item_id = 1000630,
old_price = 1.29,
new_price = 9.45,
selected = false
);
allItems.Add(new ItemModel
name = "Hashbrowns",
retail_modified_item_id = 1000739,
old_price = 0.99,
new_price = 8.5,
selected = false
);
allItems.Add(new ItemModel
name = "Amstel Light, Single",
retail_modified_item_id = 1002038,
old_price = 3.5,
new_price = 18,
selected = false
);
ItemModel.cs:
class ItemModel
public string name get; set;
public int retail_modified_item_id get; set;
public double old_price get; set;
public double new_price get; set;
public bool selected get; set;
edited Mar 28 at 10:17
answered Mar 28 at 10:04
AbbyWang - MSFTAbbyWang - MSFT
5871 silver badge6 bronze badges
5871 silver badge6 bronze badges
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
add a comment |
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
still item is showing on the list ..
– Anu Priya
Mar 28 at 10:27
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
you must refresh the listview for see changes
– Batuhan
Mar 28 at 11:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392165%2flistview-does-not-contain-a-definition-for-selecteditems%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If your issue has been completed with answer below , you can mark as completed my answer.
– Batuhan
Mar 28 at 8:50
Can you please explain what exactly are you trying to do here?
– FreakyAli
Mar 28 at 9:27
@G.hakim i want to delete the selected data after clicking reject button.i attached the delete code in reject function.but it throws error " listview does not contain a definition for selecteditem , ItemSelected"
– Anu Priya
Mar 28 at 9:30
Can you point out the line of code where this happens
– FreakyAli
Mar 28 at 9:32
foreach (var v in ProductsListView.SelectedItems) ProductsListView.ItemSelected.Remove(v); // selectedItem and itemSelected
– Anu Priya
Mar 28 at 9:34