示例#1
0
        public virtual void StyleExistsOnContainer()
        {
            ListBoxItem item = null;

            item = new ListBoxItem();
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.IsUnset(item, ListBoxItem.StyleProperty, "#1");

            CurrentControl.ItemContainerStyle = null;
            item = new ListBoxItem();
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.IsUnset(item, ListBoxItem.StyleProperty, "#2");

            CurrentControl.ItemContainerStyle = new Style(typeof(ListBoxItem));
            item = new ListBoxItem();
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.AreEqual(CurrentControl.ItemContainerStyle, item.ReadLocalValue(ListBoxItem.StyleProperty), "#3");

            Style containerStyle = new Style(typeof(ListBoxItem));

            item = new ListBoxItem {
                Style = containerStyle
            };
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.AreEqual(containerStyle, item.ReadLocalValue(ListBoxItem.StyleProperty), "#4");
        }
示例#2
0
        public virtual void PrepareContainerForItemOverrideSelector2()
        {
            Style              style = new Style(typeof(ListBoxItem));
            Selector           box   = (Selector)CurrentControl;
            DependencyProperty prop  = box is ComboBox ? ComboBox.ItemContainerStyleProperty : ListBox.ItemContainerStyleProperty;

            box.SetValue(prop, style);

            ComboBoxItem item = new ComboBoxItem();

            Assert.IsNull(item.Style, "#1");

            CurrentControl.PrepareContainerForItemOverride_(item, null);
            Assert.AreSame(item.Style, box.GetValue(prop), "#4");
        }