コード例 #1
0
        public BookmarkView()
        {
            InitializeComponent();
            this.WhenActivated(d =>
            {
                this.BindCommand(ViewModel, vm => vm.Cancel, view => view.Cancel).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.Open, view => view.Open).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.SelectedBookmark, view => view.Bookmarks.SelectedItem).DisposeWith(d);
            });

            Bookmarks.Events().MouseDoubleClick.Subscribe(x =>
            {
                System.Windows.DependencyObject obj = (System.Windows.DependencyObject)x.OriginalSource;

                while (obj != null && obj != Bookmarks)
                {
                    if (obj.GetType() == typeof(Button))
                    {
                        return;                                  //Exclude delete button
                    }
                    if (obj.GetType() == typeof(ListBoxItem))
                    {
                        ViewModel.Open.Execute().Subscribe();
                    }
                    obj = System.Windows.Media.VisualTreeHelper.GetParent(obj);
                }
            });
        }