Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
WPF - Operation is not valid while ItemsSource is in use.
Mani Kandan
Oct 31 2016 10:25 AM
1.7k
Reply
On wpf combobox DropdownClosed, I want to bind ListView.
private
void
cmbAction_DropDownClosed(
object
serder, EventArgs e)
{
int
UserID = 26;
string
Actions = cmbAction.SelectedValue.ToString();
var data = service.PostLogDetails(UserID);
if
(Actions ==
"Login"
)
{
var listItems = (from A
in
data orderby A.FirstName select
new
{ Action =
"Login"
, AccessDate = A.LogInTime });
listView1.Items.Clear();
listView1.ItemsSource = listItems;
}
else
if
(Actions ==
"Logout"
)
{
var listItems = (from A
in
data orderby A.FirstName select
new
{ Action =
"LogOut"
, AccessDate = A.LogOutTime });
listView1.Items.Clear();
listView1.ItemsSource = listItems;
}
}
After using this code, showing error.
"Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead."
How can I solve this?
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
WPF center screen issues
Reading locat storage content of wpf 8.1