TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
533
2.4k
598.2k
WPF - Operation is not valid while ItemsSource is in use.
Oct 31 2016 10:25 AM
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?
Reply
Answers (
2
)
WPF center screen issues
Reading locat storage content of wpf 8.1