コード例 #1
0
        private AccordionItem GetAccordionItem(object header, Style style, string iconPath)
        {
            AccordionItem Items3 = new AccordionItem();

            Items3.Header = header;
            Items3.Style  = style;
            BitmapImage image = new BitmapImage();

            image.UriSource = new Uri(iconPath, UriKind.Relative);
            ImageSource ima = image;

            Items3.SetValue(EyeCandy.ImageProperty, ima);

            return(Items3);
        }
コード例 #2
0
        public virtual void ShouldAllowTemplateWithUIElements()
        {
            // this tests adds back the coverage lost by the exclusion of
            // test: Content*DataTemplateWithUIElementsFails (see GetDPTests())
            AccordionItem instance = new AccordionItem();
            instance.Width = 300;
            instance.Height = 300;

            TestAsync(
                    instance,
                    () =>
                        {
                            StackPanel element = new StackPanel();
                            element.SetValue(FrameworkElement.NameProperty, "UIElementContent");
                            element.Children.Add(new Ellipse
                                                     {
                                                             Fill = new SolidColorBrush(Colors.Red),
                                                             Width = 20,
                                                             Height = 20
                                                     });
                            element.Children.Add(new TextBlock
                                                     {
                                                             Text = "UIElement Content"
                                                     });
                            element.Children.Add(new Ellipse
                                                     {
                                                             Fill = new SolidColorBrush(Colors.Blue),
                                                             Width = 20,
                                                             Height = 20
                                                     });
                            instance.SetValue(ContentControl.ContentProperty, element);
                        },
                    () => instance.IsSelected = true,
                () =>
                {
                    // Create the DataTemplate
                    XamlBuilder<DataTemplate> xamlTemplate = new XamlBuilder<DataTemplate>
                    {
                        Name = "template",
                        Children = new List<XamlBuilder>
                        {
                            new XamlBuilder<StackPanel>
                            {
                                Children = new List<XamlBuilder>
                                {
                                    new XamlBuilder<StackPanel>
                                    {
                                        AttributeProperties = new Dictionary<string, string> { { "Orientation", "Horizontal" } },
                                        Children = new List<XamlBuilder>
                                        {
                                            new XamlBuilder<TextBlock>
                                            {
                                                AttributeProperties = new Dictionary<string, string> { { "Text", "{}{Binding Name}:  " } }
                                            },
                                            new XamlBuilder<TextBlock>
                                            {
                                                Name = "nameBinding",
                                                AttributeProperties = new Dictionary<string, string> { { "Text", "{Binding Name}" } }
                                            }
                                        }
                                    },
                                    new XamlBuilder<StackPanel>
                                    {
                                        AttributeProperties = new Dictionary<string, string> { { "Orientation", "Horizontal" } },
                                        Children = new List<XamlBuilder>
                                        {
                                            new XamlBuilder<TextBlock>
                                            {
                                                AttributeProperties = new Dictionary<string, string> { { "Text", "{}{Binding}:  " } }
                                            },
                                            new XamlBuilder<ContentControl>
                                            {
                                                Name = "contentBinding",
                                                AttributeProperties = new Dictionary<string, string> { { "Content", "{Binding}" } }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    };

                    // Generate the DataTemplate and set it
                    instance.SetValue(ContentControl.ContentTemplateProperty, xamlTemplate.Load());
                },
                () =>
                {
                    // Verify the bindings didn't work
                    TextBlock text = instance.GetVisualChild("nameBinding") as TextBlock;
                    Assert.IsNotNull(text, "Failed to find nameBinding TextBlock!");
                    TestExtensions.AssertIsNullOrEmpty(text.Text);

                    ContentControl content = instance.GetVisualChild("contentBinding") as ContentControl;
                    Assert.IsNotNull(content, "Failed to find contentBinding ContentControl!");
                    Assert.IsNull(content.Content, "The bound Content should be null!");
                });
        }
コード例 #3
0
 public virtual void ShouldThrowExceptionWhenSettingContentTargetSize()
 {
     AccordionItem item = new AccordionItem();
     item.SetValue(AccordionItem.ContentTargetSizeProperty, new Size(3, 3));
 }
コード例 #4
0
 public virtual void ShouldThrowExceptionWhenSettingExpandDirectionOnAccordionItem()
 {
     AccordionItem item = new AccordionItem();
     item.SetValue(AccordionItem.ExpandDirectionProperty, ExpandDirection.Left);
 }
コード例 #5
0
        public virtual void ShouldAllowTemplateWithUIElements()
        {
            // this tests adds back the coverage lost by the exclusion of
            // test: Content*DataTemplateWithUIElementsFails (see GetDPTests())
            AccordionItem instance = new AccordionItem();

            instance.Width  = 300;
            instance.Height = 300;

            TestAsync(
                instance,
                () =>
            {
                StackPanel element = new StackPanel();
                element.SetValue(FrameworkElement.NameProperty, "UIElementContent");
                element.Children.Add(new Ellipse
                {
                    Fill   = new SolidColorBrush(Colors.Red),
                    Width  = 20,
                    Height = 20
                });
                element.Children.Add(new TextBlock
                {
                    Text = "UIElement Content"
                });
                element.Children.Add(new Ellipse
                {
                    Fill   = new SolidColorBrush(Colors.Blue),
                    Width  = 20,
                    Height = 20
                });
                instance.SetValue(ContentControl.ContentProperty, element);
            },
                () => instance.IsSelected = true,
                () =>
            {
                // Create the DataTemplate
                XamlBuilder <DataTemplate> xamlTemplate = new XamlBuilder <DataTemplate>
                {
                    Name     = "template",
                    Children = new List <XamlBuilder>
                    {
                        new XamlBuilder <StackPanel>
                        {
                            Children = new List <XamlBuilder>
                            {
                                new XamlBuilder <StackPanel>
                                {
                                    AttributeProperties = new Dictionary <string, string> {
                                        { "Orientation", "Horizontal" }
                                    },
                                    Children = new List <XamlBuilder>
                                    {
                                        new XamlBuilder <TextBlock>
                                        {
                                            AttributeProperties = new Dictionary <string, string> {
                                                { "Text", "{}{Binding Name}:  " }
                                            }
                                        },
                                        new XamlBuilder <TextBlock>
                                        {
                                            Name = "nameBinding",
                                            AttributeProperties = new Dictionary <string, string> {
                                                { "Text", "{Binding Name}" }
                                            }
                                        }
                                    }
                                },
                                new XamlBuilder <StackPanel>
                                {
                                    AttributeProperties = new Dictionary <string, string> {
                                        { "Orientation", "Horizontal" }
                                    },
                                    Children = new List <XamlBuilder>
                                    {
                                        new XamlBuilder <TextBlock>
                                        {
                                            AttributeProperties = new Dictionary <string, string> {
                                                { "Text", "{}{Binding}:  " }
                                            }
                                        },
                                        new XamlBuilder <ContentControl>
                                        {
                                            Name = "contentBinding",
                                            AttributeProperties = new Dictionary <string, string> {
                                                { "Content", "{Binding}" }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                };

                // Generate the DataTemplate and set it
                instance.SetValue(ContentControl.ContentTemplateProperty, xamlTemplate.Load());
            },
                () =>
            {
                // Verify the bindings didn't work
                TextBlock text = instance.GetVisualChild("nameBinding") as TextBlock;
                Assert.IsNotNull(text, "Failed to find nameBinding TextBlock!");
                TestExtensions.AssertIsNullOrEmpty(text.Text);

                ContentControl content = instance.GetVisualChild("contentBinding") as ContentControl;
                Assert.IsNotNull(content, "Failed to find contentBinding ContentControl!");
                Assert.IsNull(content.Content, "The bound Content should be null!");
            });
        }
コード例 #6
0
        public virtual void ShouldThrowExceptionWhenSettingContentTargetSize()
        {
            AccordionItem item = new AccordionItem();

            item.SetValue(AccordionItem.ContentTargetSizeProperty, new Size(3, 3));
        }
コード例 #7
0
        public virtual void ShouldThrowExceptionWhenSettingExpandDirectionOnAccordionItem()
        {
            AccordionItem item = new AccordionItem();

            item.SetValue(AccordionItem.ExpandDirectionProperty, ExpandDirection.Left);
        }