コード例 #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.parent = ((Uhr.ucDigit)(target));
                return;

            case 2:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;
            }
            this._contentLoaded = true;
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();
            var vm = new MainViewModel();

            this.DataContext = vm;

            // Layout aufbauen
            const int  newLine = 11;
            StackPanel sp      = null;

            for (int i = 0; i < Ziffernblatt.MaxDigits; i++)
            {
                if (i % newLine == 0)
                {
                    if (sp != null)
                    {
                        StackParent.Children.Add(sp);
                    }
                    sp = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                }
                var digi = new ucDigit();
                // Binding Selection-Property
                var propName = $"{nameof(MainViewModel.Selected)}[{i}]";
                Bind(digi, ucDigit.IsSelectedProperty, propName);
                // Binding Text-Property
                propName = $"{nameof(MainViewModel.Text)}[{i}]";
                Bind(digi, ucDigit.TextProperty, propName);
                // Add Digit
                sp.Children.Add(digi);
            }
            if (sp != null)
            {
                StackParent.Children.Add(sp);
            }
        }