I've been working on this for about an hour.
My problem is very simple:
I've a listbox like
<
listbox
istabstop
="
True"
keyboardnavigation.tabnavigation
="
Continue"
>
<
listboxitem
name
="
A"
isenabled
="
{Binding EnableA}"
content
="
aa"
>
<
/listboxitem
>
<
listboxitem
name
="
B"
content
="
bb"
>
<
/listboxitem
>
<
/listbox
>
i want to switch the IsEnabled property using EnableA in the viewmodel..
thanks in advance for any help...
public
testView(INavigationViewModel model, IEventAggregator eventaggricator)
InitializeComponent();
model viewModel =
new
model();
this
.DataContext = viewModel;
this
.eventaggricator = eventaggricator;
Hope this helps
ListBox is an Items container. so I usually set up an ObservableCollection of Models in the ViewModel; each Model has INotifyPropertyChanged for each bound property; and the Listbox is bound to the ObservableCollection using an ItemTemplate to format the displaying of each Model.
Then it is just a matter of toggling the appropriate Model's boolean property and the corresponding ListBoxItem Enabled state will change if correctly bound.
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question
and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it.
Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
private bool enableA ;
public bool EnableA
{
get { return enableA ; }
set
{
enableA = value;
this.OnPropertyChanged("EnableA");
}
}
But the ListBoxItem is always disabled.
Initially me set EnableA =true; But Stil the ListBoxItem is disabled.