WPF C# Tutorial

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    WindowTitle="Cookies Sample">
  
    
    Cookie1=Value1
    Set Cookie
    
    
    Get Cookie
  

  

//File:Window.xaml.cs
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Navigation;
namespace CookiesSampleCSharp
{
    public partial class HomePage : System.Windows.Controls.Page
    {
        public HomePage()
        {
            InitializeComponent();
        }
        void setCookieButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Application.SetCookie(BrowserInteropHelper.Source, this.setCookieValueTextBox.Text);
            }
            catch (Win32Exception ex)
            {
                MessageBox.Show(ex.Message + " (Native Error Code=" + ex.NativeErrorCode + ")");
            }
        }
        void getCookieButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.getCookieValueTextBox.Text = Application.GetCookie(BrowserInteropHelper.Source);
            }
            catch (Win32Exception ex)
            {
                MessageBox.Show(ex.Message + " (Native Error Code=" + ex.NativeErrorCode + ")");
            }
        }
    }
}