当前位置: 首页>>代码示例>>C#>>正文


C# ItemsControl类代码示例

本文整理汇总了C#中ItemsControl的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl类的具体用法?C# ItemsControl怎么用?C# ItemsControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemsControl类属于命名空间,在下文中一共展示了ItemsControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main()
        {
            var mainViewModel = new MainViewModel();

            var button = new Button()
            {
                Command = mainViewModel.PostCommand,
                TextContent = "Post"
            };

            var headerInput = new TextInput();
            headerInput.PlaceHolder = "Header";
            SimpleBinding.Create(mainViewModel, "HeaderInput", headerInput, "Value");

            var contentInput = new TextInput();
            contentInput.PlaceHolder = "Content";
            SimpleBinding.Create(mainViewModel, "ContentInput", contentInput, "Value");

            var list = new ItemsControl<Post>(new VBox())
            {
                // "postItemTemplate" is a reference to an element defined in MainPage.html
                ItemElementFactory = new TemplateElementFactory<Post>("postItemTemplate")
            };
            SimpleBinding.Create(list, "ItemsSource", mainViewModel, "Posts");

            var box = new VBox
            {
                Content = { headerInput, contentInput, button, list }
            };

            Element.GetById("target").AppendChild(box);
        }
开发者ID:xToast,项目名称:JSIL.Hacks,代码行数:32,代码来源:Program.cs

示例2: Items_Not_Should_Be_Readonly_When_ItemsSource_Nulled

 public void Items_Not_Should_Be_Readonly_When_ItemsSource_Nulled()
 {
     ItemsControl target = new ItemsControl();
     target.ItemsSource = new int[1];
     target.ItemsSource = null;
     target.Items.Add(1);
 }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:7,代码来源:ItemsControlTests.cs

示例3: Awake

 private void Awake()
 {
     m_rectTransform = GetComponent<RectTransform>();
     SiblingGraphics.SetActive(true);
     m_parentCanvas = GetComponentInParent<Canvas>();
     m_itemsControl = GetComponentInParent<ItemsControl>();
     AwakeOverride();
 }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:8,代码来源:ItemDropMarker.cs

示例4: ItemsSource_Set_Assigns_Items

        public void ItemsSource_Set_Assigns_Items()
        {
            ItemsControl target = new ItemsControl();
            int[] collection = new int[1];

            target.ItemsSource = collection;

            Assert.AreSame(collection, target.Items.SourceCollection);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:9,代码来源:ItemsControlTests.cs

示例5: Items_Should_Not_Change_Instance_When_ItemsSource_Set

        public void Items_Should_Not_Change_Instance_When_ItemsSource_Set()
        {
            ItemsControl target = new ItemsControl();
            ItemCollection before = target.Items;

            target.ItemsSource = new int[1];

            Assert.AreSame(before, target.Items);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:9,代码来源:ItemsControlTests.cs

示例6: GetItemsHostForItemsControl

 public virtual void GetItemsHostForItemsControl()
 {
     ItemsControl control = new ItemsControl { ItemsSource = new[] { 1, 2, 3, 4 } };
     Panel host = null;
     TestAsync(
         control,
         () => host = control.GetItemsHost(),
         () => Assert.IsNotNull(host, "ItemsHost not found!"));
 }
开发者ID:modulexcite,项目名称:SilverlightToolkit,代码行数:9,代码来源:ItemsControlExtensionsTest.cs

示例7: ItemsSource_Null_Unassigns_Items

        public void ItemsSource_Null_Unassigns_Items()
        {
            ItemsControl target = new ItemsControl();
            int[] collection = new int[1];

            target.ItemsSource = collection;
            target.ItemsSource = null;

            Assert.AreSame(target.Items, target.Items.SourceCollection);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:10,代码来源:ItemsControlTests.cs

示例8: Panel_Should_Have_TemplatedParent_Set_To_ItemsControl

        public void Panel_Should_Have_TemplatedParent_Set_To_ItemsControl()
        {
            var target = new ItemsControl();

            target.Template = GetTemplate();
            target.Items = new[] { "Foo" };
            target.ApplyTemplate();

            Assert.Equal(target, target.Presenter.Panel.TemplatedParent);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:10,代码来源:ItemsControlTests.cs

示例9: Adding_Control_Item_Should_Make_Control_Appear_In_LogicalChildren

        public void Adding_Control_Item_Should_Make_Control_Appear_In_LogicalChildren()
        {
            var target = new ItemsControl();
            var child = new Control();

            target.Template = GetTemplate();
            target.Items = new[] { child };
            target.ApplyTemplate();

            Assert.Equal(new[] { child }, ((ILogical)target).LogicalChildren.ToList());
        }
开发者ID:g4idrijs,项目名称:Perspex,代码行数:11,代码来源:ItemsControlTests.cs

示例10: Items_Propogates_CollectionChanged_Events

        public void Items_Propogates_CollectionChanged_Events()
        {
            ItemsControl target = new ItemsControl();
            ObservableCollection<int> collection = new ObservableCollection<int>();
            object sender = null;

            target.ItemsSource = collection;
            ((INotifyCollectionChanged)target.Items).CollectionChanged += (s, e) => sender = s;
            collection.Add(1);

            Assert.AreSame(target.Items, sender);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:12,代码来源:ItemsControlTests.cs

示例11: Control_Item_Should_Have_Parent_Set

        public void Control_Item_Should_Have_Parent_Set()
        {
            var target = new ItemsControl();
            var child = new Control();

            target.Template = GetTemplate();
            target.Items = new[] { child };
            target.ApplyTemplate();

            Assert.Equal(target, child.Parent);
            Assert.Equal(target, ((ILogical)child).LogicalParent);
        }
开发者ID:g4idrijs,项目名称:Perspex,代码行数:12,代码来源:ItemsControlTests.cs

示例12: Item_Should_Have_TemplatedParent_Set_To_Null

        public void Item_Should_Have_TemplatedParent_Set_To_Null()
        {
            var target = new ItemsControl();

            target.Template = GetTemplate();
            target.Items = new[] { "Foo" };
            target.ApplyTemplate();

            var item = (TextBlock)target.Presenter.Panel.GetVisualChildren().First();

            Assert.Null(item.TemplatedParent);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:12,代码来源:ItemsControlTests.cs

示例13: Clearing_Items_Should_Clear_Child_Controls_Parent_Before_ApplyTemplate

        public void Clearing_Items_Should_Clear_Child_Controls_Parent_Before_ApplyTemplate()
        {
            var target = new ItemsControl();
            var child = new Control();

            target.Template = GetTemplate();
            target.Items = new[] { child };
            target.Items = null;

            Assert.Null(child.Parent);
            Assert.Null(((ILogical)child).LogicalParent);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:12,代码来源:ItemsControlTests.cs

示例14: Control_Item_Should_Be_Logical_Child_Before_ApplyTemplate

        public void Control_Item_Should_Be_Logical_Child_Before_ApplyTemplate()
        {
            var target = new ItemsControl();
            var child = new Control();

            target.Template = GetTemplate();
            target.Items = new[] { child };

            Assert.Equal(child.Parent, target);
            Assert.Equal(child.GetLogicalParent(), target);
            Assert.Equal(new[] { child }, target.GetLogicalChildren());
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:12,代码来源:ItemsControlTests.cs

示例15: load

 private async void load(ItemsControl list, Uri uri)
 {
     SyndicationClient client = new SyndicationClient();
     SyndicationFeed feed = await client.RetrieveFeedAsync(uri);
     if (feed != null)
     {
         foreach (SyndicationItem item in feed.Items)
         {
             list.Items.Add(item);
         }
     }
 }
开发者ID:ELC,项目名称:La-verdad-los-har-libres-W10,代码行数:12,代码来源:Library.cs


注:本文中的ItemsControl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。