private void CNlist_SelectionChanged(object sender, SelectionChangedEventArgs e) { myModel previous = (e.PreviousSelection.FirstOrDefault() as myModel); myModel current = (e.CurrentSelection.FirstOrDefault() as myModel); //Set the current to the color you want current.FirstFrameBackColor = Color.Pink; current.SecondFrameBackColor = Color.Green; if (previous != null) { //Reset the previous to defaulr color previous.FirstFrameBackColor = Color.White; previous.SecondFrameBackColor = Color.Purple; } }
public MainPage() { InitializeComponent(); myModel model1 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; myModel model2 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; myModel model3 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; myModel model4 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; myModel model5 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; myModel model6 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; myModel model7 = new myModel() { FirstFrameBackColor = Color.White, SecondFrameBackColor = Color.Purple }; models.Add(model1); models.Add(model2); models.Add(model3); models.Add(model4); models.Add(model5); models.Add(model6); models.Add(model7); CNlist.ItemsSource = models; }