GroupBox [Solved]

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

GroupBox [Solved]

Postby CyborgDE » Fri Oct 09, 2015 5:36 am

Hello,

why does this GroupBox not work under windows, javascript is Ok, any ideas ?

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Markup;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

namespace Windows.UI.Xaml.Controls
{
    public class GroupBox : Border
    {
        private StackPanel MainGrid = null;
        private TextBlock HeaderTB = null;
        private ContentControl ContentCC = null;

        public GroupBox()
        {
            MainGrid = new StackPanel();

            //MainGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            //MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });

            HeaderTB = new TextBlock();
            HeaderTB.Text = "Header";
            MainGrid.Children.Add(HeaderTB);

            ContentCC = new ContentControl();
            MainGrid.Children.Add(ContentCC);

            Grid.SetRow(ContentCC, 1);

            BorderBrush = new SolidColorBrush(Colors.Black);
            BorderThickness = new Thickness(1);
            HeaderTB.BorderBrush = new SolidColorBrush(Colors.Black);
            HeaderTB.BorderThickness = new Thickness(1);

            base.Child = MainGrid;
        }



        public new UIElement Content
        {
            get { return (UIElement)GetValue(ContentProperty); }
            set { SetValue(ContentProperty, value); }
        }

        public static new readonly DependencyProperty ContentProperty =
            DependencyProperty.Register("Content", typeof(UIElement), typeof(GroupBox), new PropertyMetadata(null, ContentPropertyChanged));

        public static void ContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GroupBox gb = d as GroupBox;
            if (gb != null)
            {
                gb.ContentCC.Content = e.NewValue;
            }
        }


        public string Header
        {
            get { return (string)GetValue(HeaderProperty); }
            set { SetValue(HeaderProperty, value); }
        }
        public static readonly DependencyProperty HeaderProperty =
            DependencyProperty.Register("Header", typeof(string), typeof(GroupBox), new PropertyMetadata("", HeaderPropertyChanged));

        public static void HeaderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GroupBox gb = d as GroupBox;
            if (gb != null)
            {
                gb.HeaderTB.Text = e.NewValue.ToString();
            }
        }

    }
}


Regards,
CyborgDE

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: GroupBox

Postby CyborgDE » Fri Oct 09, 2015 1:17 pm

Found on other place, the GroupBox works !

Code: Select all

    public class GroupBox : Border
    {
        private StackPanel MainGrid = null;
        private TextBlock HeaderTB = null;
        private ContentControl ContentCC = null;

        public GroupBox()
        {
            MainGrid = new StackPanel();

            HeaderTB = new TextBlock();
            HeaderTB.Text = "Header";
            HeaderTB.Padding = new Thickness(4);
            MainGrid.Children.Add(HeaderTB);

            ContentCC = new ContentControl();
            MainGrid.Children.Add(ContentCC);

            Grid.SetRow(ContentCC, 1);

            BorderBrush = new SolidColorBrush(Colors.Black);
            BorderThickness = new Thickness(1);
            HeaderTB.BorderBrush = new SolidColorBrush(Colors.Black);
            HeaderTB.BorderThickness = new Thickness(0, 0, 0, 1);

            base.Child = MainGrid;
        }

        public UIElement Content
        {
            get { return (UIElement)ContentCC.GetValue(ContentControl.ContentProperty); }
            set { ContentCC.SetValue(ContentControl.ContentProperty, value); }
        }

        public string Header
        {
            get { return (string)HeaderTB.GetValue(TextBlock.TextProperty); }
            set { HeaderTB.SetValue(TextBlock.TextProperty, value); }
        }
    }


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 25 guests

 

 

cron