本文整理汇总了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);
}
示例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);
}
示例3: Awake
private void Awake()
{
m_rectTransform = GetComponent<RectTransform>();
SiblingGraphics.SetActive(true);
m_parentCanvas = GetComponentInParent<Canvas>();
m_itemsControl = GetComponentInParent<ItemsControl>();
AwakeOverride();
}
示例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);
}
示例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);
}
示例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!"));
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}
}