using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TutorialsSilverlight
{
    using Web;

    public partial class ServerSideFiltering : UserControl
    {
        public ServerSideFiltering()
        {
            InitializeComponent();
#if LIVEDEMO
            // Hide the 'Save Changes" button in the Live Demo
            // available at http://demo.componentone.com/Silverlight/StudioEntityFramework/
            button1.Visibility = System.Windows.Visibility.Collapsed;
#endif
        }

        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Update the filter value. It will trigger automatic loading.
            c1DataSource1.ViewSources["GetProducts"].FilterDescriptors[0].Value = ((Category)comboBox1.SelectedValue).CategoryID;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            c1DataSource1.ClientCache.SaveChanges();
        }
    }
}
