Exemplo n.º 1
0
        /// <summary>
        /// Accordion section was Expanded (aka selected)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnExpanderExpanded(object sender, RoutedEventArgs e)
        {
            if (currentlyExpandedExpander != null)
            {
                Expander expanderLoosing = currentlyExpandedExpander as Expander;
                expanderLoosing.IsExpanded = false;
                SetRowHeight(currentlyExpandedExpander, GridUnitType.Auto);
            }

            currentlyExpandedExpander = sender as Expander;

            SetRowHeight(sender, GridUnitType.Star);

            if (Expanded != null)
            {
                Expanded.Invoke(currentlyExpandedExpander.Content, e);
            }

            QuickFilterControl qf = WpfHelper.FindDescendantElement(currentlyExpandedExpander, nameIdOfQuickFilter) as QuickFilterControl;

            if (qf != null)
            {
                qf.Visibility = System.Windows.Visibility.Visible;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Accordion section was collapsed, in order words is not longer the selected section
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnExpanderCollapsed(object sender, RoutedEventArgs e)
        {
            if (currentlyExpandedExpander != null)
            {
                QuickFilterControl qf = WpfHelper.FindDescendantElement(currentlyExpandedExpander, nameIdOfQuickFilter) as QuickFilterControl;

                if (qf != null)
                {
                    qf.Visibility = System.Windows.Visibility.Collapsed;
                }
            }

            currentlyExpandedExpander = null;

            SetRowHeight(sender, GridUnitType.Auto);
        }
Exemplo n.º 3
0
        public void Add(string header, string id, object content, bool searchBox)
        {
            //-----------------------------------------------------------------
            // The new accordion section is build using an Expander
            //
            Expander expanderToAdd = new Expander();

            // Set dynamic reference to style so theme can be switched.
            expanderToAdd.SetResourceReference(FrameworkElement.StyleProperty, "AccordionExpander");

            expanderToAdd.Name       = id;
            expanderToAdd.IsExpanded = false;
            expanderToAdd.Margin     = new Thickness(0, 0, 0, 3);


            // The expander header is a Grid with 2 columns
            Grid expanderHeader = new Grid();

            expanderHeader.Name = "MyHeader";
            ColumnDefinition col1 = new ColumnDefinition();

            expanderHeader.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            expanderHeader.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            //-----------------------------------------------------------------
            // First column contains the Title of the accordion section
            //
            TextBlock headerText = new TextBlock();

            headerText.Text = header;
            Grid.SetColumn(headerText, 0);
            expanderHeader.Children.Add(headerText);

            //-----------------------------------------------------------------
            // Second column contains the "Quick-Filter" control
            //
            if (searchBox)
            {
                QuickFilterControl qf = new QuickFilterControl();
                qf.FilterValueChanged += new QuickFilterControl.QuickFilterValueChanged(OnFilterValueChanged);
                qf.Name = nameIdOfQuickFilter;
                qf.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                qf.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                Grid.SetColumn(qf, 1);
                expanderHeader.Children.Add(qf);
                qf.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                IContainerStatus iCS = content as IContainerStatus;
                if (iCS != null)
                {
                    TextBlock tb = new TextBlock();
                    tb.Name = nameIdOfStatusControl;
                    tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    tb.TextAlignment       = TextAlignment.Right;
                    tb.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                    tb.Margin     = new Thickness(5, 0, 0, 0);
                    tb.Visibility = System.Windows.Visibility.Visible;
                    Grid.SetColumn(tb, 1);
                    expanderHeader.Children.Add(tb);

                    iCS.SetTextBlock(tb);
                }
            }



            //-----------------------------------------------------------------
            // Set the expander header to be this new Grid we just created
            expanderToAdd.Header = expanderHeader;


            //-----------------------------------------------------------------
            // Now set the content of the expander
            //
            expanderToAdd.Content = content as UIElement;

            expanderToAdd.Expanded    += new RoutedEventHandler(OnExpanderExpanded);
            expanderToAdd.Collapsed   += new RoutedEventHandler(OnExpanderCollapsed);
            expanderToAdd.SizeChanged += new SizeChangedEventHandler(OnExpanderToAdd_SizeChanged);


            //-----------------------------------------------------------------
            // Add a new row to contain the new Accordion section
            //
            this.MainGrid.RowDefinitions.Count();
            RowDefinition rd = new RowDefinition();

            rd.Height = new GridLength(1, GridUnitType.Auto);
            this.MainGrid.RowDefinitions.Add(rd);

            // and the new Expender to the Accordion Section
            int lastRow = this.MainGrid.Children.Add(expanderToAdd);

            Grid.SetRow(expanderToAdd, lastRow);
        }