Exemplo n.º 1
0
        //ContentPresenter _presenter;


        // https://stackoverflow.com/questions/1517743/in-wpf-how-can-i-determine-whether-a-control-is-visible-to-the-user

        protected override void OnApplyTemplate()
        {
            if (_initialized)
            {
                throw new System.Exception("only call once");
            }

            base.OnApplyTemplate();

            ScrutinizeItemTemplate();

            _HeaderScrollViewer = (ScrollViewer)GetTemplateChild("HeaderScrollViewer");

            _HyperGridHeader             = (HyperGridHeader)GetTemplateChild("HeaderControl");
            _HyperGridHeader.ItemsSource = this.Header;

            _MainGrid = (Grid)GetTemplateChild("MainGrid");
            //_MainGrid.SizeChanged += MainGrid_SizeChanged;

            _ListView = (ListView)GetTemplateChild("ListView");

            // Force the ListView to load it's template, so we can get a reference to the scrollviewer.
            _ListView.ApplyTemplate();

            _scrollviewer               = VenturaVisualTreeHelper.FindDescendant <ScrollViewer>(_ListView);;
            _scrollviewer.ViewChanged  += ScrollViewer_ViewChanged;
            _ListView.SelectionChanged += ListView_SelectionChanged;
            //_ListView.PointerPressed += ListView_PointerPressed;
            _ListView.DoubleTapped += ListView_DoubleTapped;

            _ListView.SelectedIndex = this.SelectedIndex;

            _ListView.RegisterPropertyChangedCallback(ListView.SelectedItemProperty, new DependencyPropertyChangedCallback(ListView_SelectedItem_PropertyChanged));

            //// Bind HyperGrid.SelectedIndex to _ListView.SelectedIndex etc...
            //Binding b1 = new Binding { Source = this, Path = new PropertyPath("SelectedIndex"), Mode = BindingMode.TwoWay };
            //Binding b2 = new Binding { Source = this, Path = new PropertyPath("SelectedItem"), Mode = BindingMode.TwoWay };
            //_ListView.SetBinding(ListView.SelectedIndexProperty, b1);
            //_ListView.SetBinding(ListView.SelectedItemProperty, b2);

            _initialized = true;
        }