view SilverlightValidation/SilverlightGlimpse/Controls/ExceptionsViewer.xaml.cs @ 59:3591c26bd63e

MVVMLight added
author Steven Hollidge <stevenhollidge@hotmail.com>
date Sat, 21 Apr 2012 19:20:28 +0100
parents 241e2f22ed3c
children
line wrap: on
line source

using System;
using System.Windows;
using SilverlightGlimpse.Models;
using System.Windows.Controls;
using SilverlightGlimpse.Services;

namespace SilverlightGlimpse.Controls 
{
    public partial class ExceptionsViewer
    {
        public ExceptionsViewer()
        {
            InitializeComponent();
        }

        private void ClearExceptions_Click(object sender, RoutedEventArgs e)
        {
            GlimpseService.CreateInstance.HostExceptions.Clear();
        }

        private void ExceptionsViewer_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = GlimpseService.CreateInstance.HostExceptions;
            if (GlimpseService.CreateInstance.HostExceptions.Count > 0)
                this.lbExceptions.SelectedIndex = 0;
        }

        private void lbExceptions_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.lbExceptions.SelectedItem != null && this.lbExceptions.SelectedItem is ExceptionWrapper)
            {
                if (((ExceptionWrapper)this.lbExceptions.SelectedItem).IsValidationException)
                    this.tbAction.Visibility = Visibility.Visible;
                else
                    this.tbAction.Visibility = Visibility.Collapsed;
            }
        }
    }
}