From 1c036de8e527038f00b7ff07fc1ef4b80f23a846 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 27 Jun 2012 17:22:49 +0000 Subject: Started trying to add dependency objects. Don't work yet. --- .../SaveDialog.xaml.cs | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) (limited to 'Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs') diff --git a/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs b/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs index f807126..8df7b73 100644 --- a/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs +++ b/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs @@ -26,14 +26,111 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; +using Noddybox.WindowsPhone.Silverlight.ViewModels; +using System.ComponentModel; namespace Noddybox.WindowsPhone.Silverlight { + /// + /// Provides the save dialog user control. + /// public partial class SaveDialog : UserControl { + #region Private data + + private FileDialogViewModel model; + + #endregion + + #region Constructors + + /// + /// Construct a save dialog. + /// public SaveDialog() { InitializeComponent(); + + if (!DesignerProperties.IsInDesignTool) + { + model = new FileDialogViewModel("/"); + DataContext = model; + } + } + + #endregion + + #region Properties + + public static readonly DependencyProperty StartPathProperty = + DependencyProperty.Register("StartPath", typeof(string), typeof(SaveDialog), null); + // new PropertyMetadata("StartPath", new PropertyChangedCallback(SaveDialog.OnStartPathChanged))); + + public static readonly DependencyProperty OkButtonTextProperty = + DependencyProperty.Register("OkButtonText", typeof(string), typeof(SaveDialog), null); + // new PropertyMetadata("StartPath", new PropertyChangedCallback(SaveDialog.OnStartPathChanged))); + + private static void OnStartPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + } + + /// + /// Set the start path + /// + public string StartPath + { + set + { + if (!DesignerProperties.IsInDesignTool) + { + model.Path = value; + } + } + } + + /// + /// Set the contents of the OK button. + /// + public string OkButtonText + { + set + { + } } + + /// + /// Set the contents of the Cancel button. + /// + public string CancelButtonText + { + set {cancelButton.Content = value;} + } + + #endregion + + #region Event handlers + + private void OnFilenameKeyUp(object sender, KeyEventArgs e) + { + model.Filename = fileName.Text; + } + + private void OnOKButton(object sender, RoutedEventArgs e) + { + } + + private void OnCancelButton(object sender, RoutedEventArgs e) + { + } + + private void OnFileListSelection(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count > 0) + { + model.FileSelected((FileInfo)e.AddedItems[0]); + } + } + + #endregion } } -- cgit v1.2.3