Пример #1
0
        private void BindFilter(CompositeDisposable disposables)
        {
            this.FilterTypeComboBox.AddEnumValues <FilterType>();

            this.Bind(this.ViewModel, vm => vm.FilterType, v => v.FilterTypeComboBox.SelectedItem)
            .DisposeWith(disposables);

            var filterOperationConverter = Locator.Current.GetService <IEnumConverter <FilterOperation> >();

            this.ViewModel !.AvailableOperations
            .ToObservableChangeSet()
            .Transform(filterOperationConverter.ToString)
            .ToCollection()
            .Subscribe(ops =>
            {
                this.FilterOperationComboBox.Items.Clear();
                ops.ForEach(op => this.FilterOperationComboBox.Items.Add(op));
            })
            .DisposeWith(disposables);

            this.Bind(this.ViewModel, vm => vm.FilterOperation, v => v.FilterOperationComboBox.SelectedItem)
            .DisposeWith(disposables);

            this.WhenAnyValue(v => v.ViewModel !.FilterOperation)
            .Select(op => op != FilterOperation.None)
            .BindTo(this, v => v.FilterOperationComboBox.Visibility)
            .DisposeWith(disposables);

            this.Bind(this.ViewModel !, vm => vm.IsNegated, v => v.NegateCheckBox.IsChecked)
            .DisposeWith(disposables);

            this.OneWayBind(
                this.ViewModel !,
                vm => vm.IsNegated,
                v => v.ColorStripRectangle.Visibility,
                BooleanToVisibilityHint.UseHidden)
            .DisposeWith(disposables);

            this.WhenAnyValue(v => v.ViewModel !.FilterOperation)
            .Select(op => op != FilterOperation.None ? 1 : 0)
            .Subscribe(gridRow => Grid.SetRow(this.NegateCheckBox, gridRow))
            .DisposeWith(disposables);

            this.Bind(this.ViewModel, vm => vm.FilterInput, v => v.InputViewHost.ViewModel)
            .DisposeWith(disposables);
        }
    private void BindFilter(CompositeDisposable disposables)
    {
        this.FilterTypeComboBox.SetEnumValues <FilterType>();

        this.Bind(this.ViewModel, vm => vm.FilterType, v => v.FilterTypeComboBox.SelectedItem)
        .DisposeWith(disposables);

        var filterOperationConverter = GetDefaultService <IEnumConverter <FilterOperation> >();

        this.ViewModel !.AvailableOperations
        .ToObservableChangeSet()
        .Transform(filterOperationConverter.ToString)
        .ToCollection()
        .Subscribe(ops => this.FilterOperationComboBox.Items = ops.ToList())
        .DisposeWith(disposables);

        this.Bind(this.ViewModel, vm => vm.FilterOperation, v => v.FilterOperationComboBox.SelectedItem)
        .DisposeWith(disposables);

        this.WhenAnyValue(v => v.ViewModel !.FilterOperation)
        .Select(op => op != FilterOperation.None)
        .BindTo(this, v => v.FilterOperationComboBox.IsVisible)
        .DisposeWith(disposables);

        this.Bind(this.ViewModel !, vm => vm.IsNegated, v => v.NegateCheckBox.IsChecked)
        .DisposeWith(disposables);

        this.OneWayBind(this.ViewModel !, vm => vm.IsNegated, v => v.ColorStripRectangle.IsVisible)
        .DisposeWith(disposables);

        this.WhenAnyValue(v => v.ViewModel !.FilterOperation)
        .Select(op => op != FilterOperation.None)
        .BindTo(this, v => v.FilterOperationCaption.IsVisible)
        .DisposeWith(disposables);

        this.WhenAnyValue(v => v.ViewModel !.FilterOperation)
        .Select(op => op != FilterOperation.None ? 2 : 1)
        .Subscribe(gridRow => Grid.SetRow(this.NegateGrid, gridRow))
        .DisposeWith(disposables);

        this.Bind(this.ViewModel, vm => vm.FilterInput, v => v.InputViewHost.ViewModel)
        .DisposeWith(disposables);
    }