using System; using System.Windows; using System.Windows.Controls; using MahTweets.Mobile.Core.Services; namespace MahTweets.Mobile.Core { public static class ActionsBar { public static DependencyProperty TypeProperty = DependencyProperty.RegisterAttached("Type", typeof (string), typeof (ActionsBar), null); public static DependencyProperty ShowProperty = DependencyProperty.RegisterAttached("Show", typeof (bool), typeof (ActionsBar), new PropertyMetadata(ShowChanged)); public static INavigationService NavigationService { get; set; } private static void ShowChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var t = Type.GetType(GetType(d), true); if (t == null) return; var instance = (ActionsBarBase)Activator.CreateInstance(t); instance.Initialise(NavigationService, (AbstractStatusUpdate) ((Control) d).DataContext); ((ContentControl) d).Content = (bool) e.NewValue ? instance : null; } public static void SetShow(DependencyObject o, bool value) { o.SetValue(ShowProperty, value); } public static bool GetShow(DependencyObject o) { return (bool) o.GetValue(ShowProperty); } public static void SetType(DependencyObject o, string value) { o.SetValue(TypeProperty, value); } public static string GetType(DependencyObject o) { return (string)o.GetValue(TypeProperty); } } }