Radio button inside listView is not triggering in Xamarin.Android - xamarin

I have declared a listView like this :
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/listview"
local:MvxBind="ItemsSource QuestionList; ItemClick ButtonClick"
local:MvxItemTemplate="#layout/item_questions"
android:clickable="true"
android:layout_margin="10dp"
android:layout_marginBottom="20dp" />
Now my item template contains choice mode questions which is rendering as per the requirement but whenever i click on any radio button its not triggering any event. I have take all the selected values from the radio button.
Below is my code of item template:
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton1"
android:textColor="#000000"
android:clickable="true"
local:MvxBind="Text OptionA; Click ItemChecked" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
local:MvxBind="Text OptionB; Click ItemChecked"
android:id="#+id/radioButton2" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
local:MvxBind="Text OptionC; Click ItemChecked"
android:id="#+id/radioButton3" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
local:MvxBind="Text OptionD; Click ItemChecked"
android:id="#+id/radioButton4" />
</RadioGroup>
I also implemented the wrapper class as suggested. Below is my wrapper class code:
public class ListViewWrapper
{
Question _question;
QuestionsViewModel _parent;
public ListViewWrapper()
{
}
public ListViewWrapper(Question radio, QuestionsViewModel parent)
{
_question = radio;
_parent = parent;
}
public IMvxCommand ItemChecked
{
get
{
return new MvxCommand(() => _parent.btnClick(_question));
}
}
public Question Item
{
get
{
return _question;
}
}
}
Here's ViewModel :
private IMvxCommand _buttonClick;
public IMvxCommand ButtonClick
{
get
{
_buttonClick = _buttonClick ?? new MvxCommand<Question>(btnClick);
return _buttonClick;
}
}
public void btnClick(Question item)
{
//Do something
}

Related

What property do you use to bind data to axml layout in MvvmLight?

I've been for two whole days trying to figure out how do you bind data and commands to layout elements like a button or a listView and up until now I have had no success heres what I have as an example of one of my layouts.
Can you Help me?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/srlStores"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="80"
local:MvxBind="Refreshing IsBusy">
<MvxListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lvStores"
local:MvxBind="ItemsSource Stores; ItemClick OpenDetailCommand"
local:MvxItemTemplate="#layout/store_list_item" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="20"
android:id="#+id/progressBar1"
local:MvxBind="Visible IsBusy" />
<Button
android:text="#string/storeListCreateButtonText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bCreate"
android:layout_weight="20"
local:MvxBind="Click CreateCommand" />
</LinearLayout>
You are extremely close. You have to make sure the ViewModel is setup properly, and then just go into the ViewModel that is associated with that Fragment which this Layout belongs to and for the button add this:
private IMvxCommand _createCommand;
public IMvxCommand CreateCommand
{
get
{
return createCommand ?? (createCommand = new MvxCommand(() =>
{
// Do Some Work
}));
}
}
Similarly for your List, you need to create an ObservableCollection like this:
private ObservableCollection<StoreListModelWrapper> _stores;
public ObservableCollection<StoreListModelWrapper> Stores
{
get { return _stores; }
set { SetProperty(ref _stores, value); }
}
that will be called using the click command
public IMvxCommand<StoreListModelWrapper> _itemClickCommand;
public IMvxCommand<StoreListModelWrapper> ItemClickCommand
{
get
{
return _itemClickCommand ?? (_itemClickCommand = new MvxCommand<StoreListModelWrapper>((item) => // Do Work with item.
));
}
}

MvvmCross Android binding EditText in release mode

I have a problem with binding EditText on Android platform.
Today I update in my project MvvmCross framework from 6.2.X to 6.3.1 (+ update others NuGets) and changed TargetSdk and CompileSdk from Android 8.1 to 9.0 and now when I have Release mode and linking set to "Sdk Assemblies" Only my app crash on View where I have binding EditText. In debug where I have checked "Use Shared Runtime" and set linking to "None" there is no problem it works.
I have Include TextView in LinkerPleaseInclude:
public void Include(TextView text)
{
text.AfterTextChanged += (sender, args) => text.Text = $"{text.Text}";
text.Hint = $"{text.Hint}";
}
it throws this exception: https://pastebin.com/EmkuL7hM
Layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:paddingTop="50dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backgroundColor">
<LinearLayout
android:layout_margin="10dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:id="#+id/logo"
android:layout_width="200dp"
android:layout_height="100dp"
android:src="#drawable/ic_logo_red"
android:scaleType="fitCenter" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:text="Email"
local:MvxLang="Text Email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/primaryColor"
android:textStyle="bold"
android:textSize="#dimen/text_medium" />
<EditText
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="40dp"
local:MvxBind="Text LoginName"
android:singleLine="true"
android:inputType="textEmailAddress"
android:background="#color/white"
android:cursorVisible="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColorHint="#color/primaryTextColor"
android:textColor="#color/primaryTextColor" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:text="Password"
local:MvxLang="Text Password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/primaryColor"
android:textStyle="bold"
android:textSize="#dimen/text_medium" />
<EditText
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="40dp"
local:MvxBind="Text Password"
android:singleLine="true"
android:inputType="textPassword"
android:background="#color/white"
android:cursorVisible="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColorHint="#color/primaryTextColor"
android:textColor="#color/primaryTextColor" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:gravity="center"
android:id="#+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_large"
local:MvxLang="Text Login"
local:MvxBind="Click LoginCommand"
android:padding="10dp"
android:background="#drawable/button_round_primary"
android:textColor="#color/white"
android:text="Login"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
ViewModel:
public class LoginViewModel : MvxViewModel
{
private readonly IMvxNavigationService _navigationService;
private readonly IInfoMessageReporter _infoMessageReporter;
private readonly ISessionInfo _session;
private readonly ILoginService _loginService;
private readonly IDataService _dataService;
public LoginViewModel()
{
_navigationService = Mvx.IoCProvider.Resolve<IMvxNavigationService>();
_infoMessageReporter = Mvx.IoCProvider.Resolve<IInfoMessageReporter>();
_session = Mvx.IoCProvider.Resolve<ISessionInfo>();
_loginService = Mvx.IoCProvider.Resolve<ILoginService>();
_dataService = Mvx.IoCProvider.Resolve<IDataService>();
RememberLogin = true;
}
public IMvxLanguageBinder TextSource => new MvxLanguageBinder(Constants.LocalizationNamespace, GetType().Name);
public override async Task Initialize()
{
await InitializePermissionsAsync();
}
private async Task InitializePermissionsAsync()
{
// some stuff...
}
private string _password;
public string Password
{
get => _password;
set
{
_password = value;
RaisePropertyChanged(() => Password);
}
}
private string _loginName;
public string LoginName
{
get => _loginName;
set
{
_loginName = value;
RaisePropertyChanged(() => LoginName);
}
}
private MvxAsyncCommand _loginCommand;
public IMvxAsyncCommand LoginCommand
{
get
{
_loginCommand = _loginCommand ?? new MvxAsyncCommand(async () => await ExecuteLoginAsync());
return _loginCommand;
}
}
private async Task ExecuteLoginAsync()
{
// some stuff....
}
}
I believe the issue you are experiencing is a current bug in Xamarin's latest build (around Xamarin Android 9.4). This issue can be tracked here on GitHub.
The suggested workaround
In case any other users come across this issue when using
Xamarin.Android 9.4, a possible workaround is to use a custom linker
configuration to preserve the missing types. To do that, add a new
linker.xml file to the project, set the Build Action to
LinkDescription, and add the XML lines to preserve the missing types.
For example, for the ITextWatcherInvoker error, add the following
lines to the file:
<linker>
<assembly fullname="Mono.Android">
<type fullname="Android.Text.ITextWatcherInvoker" preserve="all" />
</assembly>
</linker>

xamarin andriod popupwindow custom listview itemclick event not working

list.ItemClick+= not working. How I can perform item click on popup window custom listview? In simple listview the itemclick event works, but in the popup window the event is not fired. I need to get the listview item value.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="500dp"
android:gravity="center"
android:descendantFocusability="blocksDescendants"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:weightSum="100">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_weight="10"
android:layout_height="40dp">
<TextView
android:text="Vælg din afdeling"
android:textSize="20sp"
android:textColor="#FF222222"
android:paddingLeft="30dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px"
android:id="#+id/textView1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="50">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:focusable="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listView1" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="35dp">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<Button
android:id="#+id/btnAddExpense"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:textColor="#61222222"
android:background="#null"
android:text="Annuller"
android:layout_marginLeft="20dp"
android:layout_gravity="right"
android:layout_marginRight="15dp" />
<Button
android:id="#+id/btnok"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:textColor="#FFF62F5E"
android:text="Gem"
android:background="#null"
android:layout_marginLeft="1dp"
android:layout_gravity="right"
android:layout_marginRight="15dp" />
</LinearLayout>
</LinearLayout>
In this function, I set item click event on listview but it is not working. How can I perform itemclick?
private void DepartmentPicker_Click(object sender, EventArgs e)
{
ButtonNext.Visibility = ViewStates.Invisible;
GetListView.Adapter = new DepartmentListAdapter(this, departments);
bool focusable = true;
int width = 350;// LinearLayout.LayoutParams.WrapContent;
int height = 450;//LinearLayout.LayoutParams.WrapContent;
_view.FindViewById<Button>(Resource.Id.btnok).SetOnClickListener(this);
var list= _view.FindViewById<ListView>(Resource.Id.listView1);
popupWindow = new PopupWindow(_view, width, height, focusable);
popupWindow.ContentView = _view;
popupWindow.ShowAtLocation(_view, GravityFlags.CenterVertical, 0, 0);
popupWindow.Focusable = true;
popupWindow.Touchable = true;
//listView.ChoiceMode = ChoiceMode.Single;
}
I wrote a demo about it, this is running GIF.
There is my code of MainActivity.cs
public class MainActivity : AppCompatActivity
{
List<News> data;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
Button button1 = FindViewById<Button>(Resource.Id.button1);
button1.Click += (o, e) =>
{
var popup = OnClick();
popup.ShowAsDropDown((View)o, 0, 0);
};
data = new List<News>() {
new News ("aaaaaaaa",1200),
new News ("bbbbbbbbb",560),
new News ("ccccccccc",158200),
new News ("ddddddddd",900),
};
// adapter = new NewsAdapter(data, this);
}
private PopupWindow OnClick()
{
PopupWindow _popupWindow = new PopupWindow(this);
LayoutInflater inflater= (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
View popup=inflater.Inflate(Resource.Layout.window_popup_content,null);
ListView listView1 = popup.FindViewById<ListView>(Resource.Id.listView1);
NewsAdapter adapter = new NewsAdapter(data, this);
listView1.Adapter = adapter;
listView1.ItemClick += (sender, args) =>
{
Toast.MakeText(this, data[args.Position].Title + "", ToastLength.Short).Show();
_popupWindow.Dismiss();
};
_popupWindow.Width = ViewGroup.LayoutParams.WrapContent;
_popupWindow.Height = ViewGroup.LayoutParams.WrapContent;
_popupWindow.ContentView = popup;
return _popupWindow;
}
}
There is adapter of listview.
public class NewsAdapter : BaseAdapter
{
private List<News> data;
private Context context;
public override int Count
{
get
{
return data.Count;
}
}
public NewsAdapter(List<News> data, Context context)
{
this.data = data;
this.context = context;
}
public override Java.Lang.Object GetItem(int position)
{
return null;
}
public override long GetItemId(int position)
{
return position;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
convertView = LayoutInflater.From(context).Inflate(Resource.Layout.lv_test, parent, false);
TextView title = convertView.FindViewById<TextView>(Resource.Id.tv_title);
TextView pv = convertView.FindViewById<TextView>(Resource.Id.tv_pv);
pv.Text = data[position].Pv.ToString();
title.Text = data[position].Title;
return convertView;
}
xaml of ListviewItem
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<LinearLayout
android:id="#+id/layout_content"
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:id="#+id/tv_title"
android:layout_height="20dp"
android:layout_width="0dp"
android:layout_weight="5"
android:textColor="#000000"
android:text="aaaaaaaaa"
android:textSize="16dp" />
<TextView
android:id="#+id/tv_pv"
android:layout_height="10dp"
android:layout_width="0dp"
android:layout_weight="1"
android:textColor="#808080"
android:textSize="10dp"
android:text="19665"
android:gravity="right|center_vertical" />
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="#dedede" />
</LinearLayout>
There is my demo. you could refer to it.
https://github.com/851265601/ListviewPopUpWindowDemo

MvvmCross 6 RecyclerView multiple buttons item binding

I'm really new in Xamarin & more in MvvmCross. For the moment, I succeeded doing some basic stuff.
But now, I'm facing a simple problem (for me). I got an MvxRecyclerView. Each of its items has 2 buttons. How can I bind them?
Given your ViewModels:
public class MyViewModel : MvxViewModel
{
public MyViewModel()
{
this.MyItems.Add(new MyItemViewModel());
this.MyItems.Add(new MyItemViewModel());
}
public ObservableCollection<MyItemViewModel> MyItems { get; set; } = new ObservableCollection<MyItemViewModel>();
}
public class MyItemViewModel : MvxNotifyPropertyChanged
{
public MyItemViewModel()
{
// Initialize your commands
}
public ICommand MyCommand1 { get; set; }
public ICommand MyCommand2 { get; set; }
}
In your view:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<mvvmcross.droid.support.v7.recyclerview.MvxRecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
local:MvxItemTemplate="#layout/item_test"
local:MvxBind="ItemsSource MyItems" />
</LinearLayout>
In your item view item_test.axml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My button 1"
local:MvxBind="Click MyCommand1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My button 2"
local:MvxBind="Click MyCommand2" />
</LinearLayout>
HIH

Capture checkbox event in the recyclerview

I have MainViewModel where it shows all the person as a list using recyclerview. Each person has age, gender, name property and also checkbox in order to delete it.
I could not able to figure out how I could able to capture user checkbox event in the MainViewModel?
MainView.axml
<CheckBox
android:id="#+id/checkbox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
local:MvxBind="Checked IsAllSelected" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Name"
android:layout_weight="1" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Age" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Gender" />
</LinearLayout>
<MvxRecyclerView
android:id="#+id/personRecyclerView"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
local:MvxItemTemplate="#layout/persontemplate"
local:MvxBind="ItemsSource Items; ItemClick ItemSelected" />
</LinearLayout>
PersonTemplate.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_height="60dp">
<CheckBox
android:id="#+id/chked"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
local:MvxBind="Checked IsSelected; Click CheckBoxSelectionCommand;" />
<TextView
android:id="#+id/Name"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Name"
android:layout_weight="1" />
<TextView
android:id="#+id/Age"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Age"
android:layout_weight="1" />
<TextView
android:id="#+id/Gender"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Gender
android:layout_weight="1" />
</LinearLayout>
I am trying to update IsDeleteBtnShow based on the checkbox selection for each item.
MainViewModel.cs
public bool IsAllSelected
{
get { return _isAllSelected; }
set
{
_isAllSelected= value;
Items.ForEach(x => x.IsSelected = _isAllSelected);
IsDeleteBtnShow = _isAllSelected;
RaisePropertyChanged(() => IsAllSelected);
}
}
I have the following viewmodel which is used by RecyclerView to tabulate person as a list.
PersonRecyclerViewModel.cs
public bool IsSelected
{
get { return _isSelected; }
set
{
_isSelected = value;
RaisePropertyChanged(() => IsSelected);
}
}
public ICommand CheckBoxSelectionCommand
{
get
{
return new MvxCommand(() =>
{
var isChecked = IsSelected;
});
}
}
public static PersonViewModel CreateViewModel(Person person)
{
return new PersonViewModel
{
IsSelected = person.IsSelected,
Age= person.Age,
Gender= person.Gender,
Name= entity.Name,
};
}
You can just pass a callback or command to the cration of the ItemViewModel. CreateViewModel(Person person, Action<PersonViewModel> checkboxSelectedCallback) and use it directly as or in CheckBoxSelectionCommand. Something like this:
CheckBoxSelectionCommand
public ICommand CheckBoxSelectionCommand
{
get
{
return new MvxCommand(() =>
{
var isChecked = IsSelected;
ParentCheckBoxSelectionCallback(this);
});
}
}
CreateViewModel
public static PersonViewModel CreateViewModel(Person person, Action<PersonViewModel> checkboxSelectedCallback)
{
return new PersonViewModel
{
IsSelected = entity.IsSelected,
Age = entity.Age,
ParentCheckBoxSelectionCallback = checkboxSelectedCallback,
Gender= entity.Gender,
Name= entity.Name,
};
}
MainViewModel
// only create once.
_checkedChangedCallback = (person =>
{
// do what you have to do if a item got selected
});
// where you create persons
CreateViewModel(person, _checkedChangedCallback );
Another way to do this without adding Actions or any logic in your model is to make your model implement INotifyPropertyChanged:
class PersonRecyclerViewModel : INotifyPropertyChanged
The quickest way to do it is using Fody PropertyChanged because you´ll get the whole implementation of the interface by just adding an attribute to the model:
[ImplementPropertyChanged]
class PersonRecyclerViewModel {}
In your ViewModel, when you get or refresh data source, a for loop would listen for item property changes:
foreach(var item in Items)
{
var n = (INotifyPropertyChanged)item;
n.PropertyChanged += OnItemPropertyChanged;
}
private void OnItemPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
{
if(propertyChangedEventArgs.PropertyName == "IsSelected")
{
// do whatever you need here
}
}

Resources