Пример #1
0
        /////////////////// Event Handlers


//<SnippetRoutedPropertyChangedEvent>
        private void OnChildrenCountChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            int childrenCount = (int)Math.Floor(e.NewValue + 0.5);

            //  Update the children count...
            AutoIndexingGrid g = (AutoIndexingGrid)LogicalTreeHelper.FindLogicalNode(myWindow, "TargetGrid");

            while (g.Children.Count < childrenCount)
            {
                Control c = new Control();
                g.Children.Add(c);
                c.Style = (Style)c.FindResource("ImageWithBorder");
            }
            while (g.Children.Count > childrenCount)
            {
                g.Children.Remove(g.Children[g.Children.Count - 1]);
            }

            // <Snippet6>

            //  Update TextBlock element displaying the count...
            TextBlock t = (TextBlock)LogicalTreeHelper.FindLogicalNode(myWindow, "ChildrenCountDisplay");

            t.Text = childrenCount.ToString();
            //</Snippet6>
        }
Пример #2
0
//</SnippetRoutedPropertyChangedEvent>

        private void OncolumnCountChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            int columnCount = (int)Math.Floor(e.NewValue + 0.5);

            //  Update column count...
            AutoIndexingGrid g = (AutoIndexingGrid)LogicalTreeHelper.FindLogicalNode(myWindow, "TargetGrid");

            while (g.ColumnDefinitions.Count < columnCount)
            {
                g.ColumnDefinitions.Add(new ColumnDefinition());
            }
            while (g.ColumnDefinitions.Count > columnCount)
            {
                g.ColumnDefinitions.Remove(g.ColumnDefinitions[g.ColumnDefinitions.Count - 1]);
            }

            //  Update TextBlock element displaying the count...
            TextBlock t = (TextBlock)LogicalTreeHelper.FindLogicalNode(myWindow, "ColumnCountDisplay");

            t.Text = columnCount.ToString();
        }