• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ItemsControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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();

            var presenter = target.GetTemplateChildren().OfType<ItemsPresenter>().Single();
            var panel = target.GetTemplateChildren().OfType<StackPanel>().Single();

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


示例17: Container_Should_Have_TemplatedParent_Set_To_Null

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

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

            var container = (ContentPresenter)target.Presenter.Panel.Children[0];

            Assert.Null(container.TemplatedParent);
        }
开发者ID:jazzay,项目名称:Avalonia,代码行数:13,代码来源:ItemsControlTests.cs


示例18: 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 presenter = target.GetTemplateChildren().OfType<ItemsPresenter>().Single();
            var panel = target.GetTemplateChildren().OfType<StackPanel>().Single();
            var item = (TextBlock)panel.GetVisualChildren().First();

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


示例19: Control_Item_Should_Be_Removed_From_Logical_Children_Before_ApplyTemplate

        public void Control_Item_Should_Be_Removed_From_Logical_Children_Before_ApplyTemplate()
        {
            var target = new ItemsControl();
            var child = new Control();
            var items = new AvaloniaList<Control>(child);

            target.Template = GetTemplate();
            target.Items = items;
            items.RemoveAt(0);

            Assert.Null(child.Parent);
            Assert.Null(child.GetLogicalParent());
            Assert.Empty(target.GetLogicalChildren());
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:14,代码来源:ItemsControlTests.cs


示例20: Adding_String_Item_Should_Make_TextBlock_Appear_In_LogicalChildren

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

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

            var logical = (ILogical)target;
            Assert.Equal(1, logical.LogicalChildren.Count);
            Assert.IsType<TextBlock>(logical.LogicalChildren[0]);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:14,代码来源:ItemsControlTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ItemsList类代码示例发布时间:2022-05-24
下一篇:
C# ItemsChangedEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap