1: using System;
2: using System.ServiceModel;
3: using System.Windows;
4: using System.Windows.Browser;
5: using System.Windows.Controls;
6:
7: using BlogEngine.UI.BlogEngineServiceRef;
8:
9: namespace BlogEngine.UI
10: {
11: public partial class ComboBoxDemo : UserControl
12: {
13: public ComboBoxDemo()
14: {
15: InitializeComponent();
16: this.Loaded += new RoutedEventHandler(ComboBoxDemo_Loaded);
17: }
18:
19: protected void ComboBoxDemo_Loaded(object sender, RoutedEventArgs e)
20: {
21: BasicHttpBinding binding = new BasicHttpBinding();
22: EndpointAddress address =
23: new EndpointAddress(
24: new Uri(Application.Current.Host.Source,
25: "../themes/13sides v2/BlogEngineService.svc").ToString());
26:
27: BlogEngineServiceClient client = new BlogEngineServiceClient(binding, address);
28: client.FetchPostInfoCompleted += new EventHandler<FetchPostInfoCompletedEventArgs>(FetchPostInfoCompleted);
29: client.FetchPostInfoAsync();
30: }
31:
32: #region Asynch
33: protected void FetchPostInfoCompleted(object sender, FetchPostInfoCompletedEventArgs e)
34: {
35: if (e.Error == null)
36: {
37: cbItems.ItemsSource = e.Result;
38: }
39: }
40: #endregion
41:
42: #region Event Handlers
43: private void Items_SelectionChanged(object sender, SelectionChangedEventArgs e)
44: {
45: PostInfo p = (PostInfo)cbItems.SelectedItem;
46: HtmlPage.Window.Navigate(new Uri(p.AbsolutleLink));
47: }
48: #endregion
49: }
50: }