public CalendarView() { InitializeComponent(); //Name="ocv" CurrentViewMode="{Binding CurrentViewMode, Mode=TwoWay}" DateNavigator="{Binding DateNavigator}" //DataManager = "{Binding DataManager}" ActiveCalendar = "{Binding ActiveCalendar, Mode=OneWayToSource}" XamOutlookCalendarView view = new XamOutlookCalendarView(); view.Name = "ocv"; Binding commandBinding = new Binding(); commandBinding.Source = DataContext; commandBinding.Path = new PropertyPath("SelectedTimeRangeChangedCommand"); EventToCommand eventToCommand = new EventToCommand(); eventToCommand.EventArgsConverter = new XamOutlookCalendarViewSelectedTimeRangeChangedConverter(); BindingOperations.SetBinding(eventToCommand, EventToCommand.CommandProperty, commandBinding); var triggers = Interaction.GetTriggers(view); var eventTrigger = new System.Windows.Interactivity.EventTrigger() { EventName = "SelectedTimeRangeChanged" }; eventTrigger.Actions.Add(eventToCommand); triggers.Add(eventTrigger); Binding currentViewModeBinding = new Binding(); currentViewModeBinding.Source = DataContext; currentViewModeBinding.Path = new System.Windows.PropertyPath("CurrentViewMode"); currentViewModeBinding.Mode = BindingMode.TwoWay; view.SetBinding(XamOutlookCalendarView.CurrentViewModeProperty, currentViewModeBinding); Binding dateNavigatorBinding = new Binding(); dateNavigatorBinding.Source = DataContext; dateNavigatorBinding.Path = new System.Windows.PropertyPath("DateNavigator"); view.SetBinding(XamOutlookCalendarView.DateNavigatorProperty, dateNavigatorBinding); Binding dataManagerBinding = new Binding(); dataManagerBinding.Source = DataContext; dataManagerBinding.Path = new System.Windows.PropertyPath("DataManager"); view.SetBinding(XamOutlookCalendarView.DataManagerProperty, dataManagerBinding); Binding activeCalendarBinding = new Binding(); activeCalendarBinding.Source = DataContext; activeCalendarBinding.Path = new System.Windows.PropertyPath("ActiveCalendar"); activeCalendarBinding.Mode = BindingMode.OneWayToSource; view.SetBinding(XamOutlookCalendarView.ActiveCalendarProperty, activeCalendarBinding); _placeHolder.Children.Add(view); }
private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { XamOutlookCalendarView outlookCalendarView = dependencyObject as XamOutlookCalendarView; if (outlookCalendarView != null) { XamOutlookCalendarViewCommandBehavior behavior = GetOrCreateBehavior(outlookCalendarView); behavior.CommandParameter = e.NewValue; } }
private static XamOutlookCalendarViewCommandBehavior GetOrCreateBehavior(XamOutlookCalendarView outlookCalendarView) { XamOutlookCalendarViewCommandBehavior behavior = outlookCalendarView.GetValue(SelectedTimeRangeCommandBehaviorProperty) as XamOutlookCalendarViewCommandBehavior; if (behavior == null) { behavior = new XamOutlookCalendarViewCommandBehavior(outlookCalendarView); outlookCalendarView.SetValue(SelectedTimeRangeCommandBehaviorProperty, behavior); } return(behavior); }
public static void SetCommandParameter(XamOutlookCalendarView outlookCalendarView, object parameter) { outlookCalendarView.SetValue(CommandParameterProperty, parameter); }
public static object GetCommandParameter(XamOutlookCalendarView outlookCalendarView) { return(outlookCalendarView.GetValue(CommandParameterProperty)); }
public static void SetCommand(XamOutlookCalendarView menuItem, ICommand command) { menuItem.SetValue(CommandProperty, command); }
public static ICommand GetCommand(XamOutlookCalendarView outlookCalendarView) { return(outlookCalendarView.GetValue(CommandProperty) as ICommand); }