itemscontrol

FlowLayout ItemsControl in WPF

落爺英雄遲暮 提交于 2019-12-24 02:35:14
问题 I need a really simple ItemsControl actually. I want all the items in the collection to be put left to right and when it's not enough space to fit the next element, it should be put on the next line. So basically like FlowLayout in Java Swing, or the normal Icon folder view in Windows. I can't believe this is not built in, but for some reason I can't find it. 回答1: Have a look at these: http://msdn.microsoft.com/en-us/library/ms750564%28v=vs.85%29.aspx Specifically the WrapPanel Edit: The

Append Items to Databound ItemsControl in WPF

烂漫一生 提交于 2019-12-24 01:17:47
问题 I've got a Combo Box that is databound to an ObservableCollection of items. I would like to have a default selected item that is (None) that would set the value of the property I've bound to "SelectedValue" to null. I think there ought to be a way to achieve this with some combination of Style/DataTemplate/TemplateSelector. I'm trying to design this with MVVM in mind, so I'd like something that doesn't use codebehind and is as reusable as possible. I'd also like the benefits of the

Alignment of nested databinding with ItemsControl in C# WPF

喜你入骨 提交于 2019-12-24 00:53:53
问题 I have the following datatemplate: <ItemsControl x:Name="Groups" ItemsSource="{Binding Groups}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel x:Name="GroupStackPanel" Orientation="Horizontal"> <GroupBox Header="{Binding Path=GroupName}"> <ItemsControl ItemsSource="{Binding Buttons}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel x:Name="BtnStackPanel" Orientation="Horizontal"> <Button Content="{Binding Path=LabelString}" Command="{Binding Path=ButtonCommand}"/> </StackPanel

How to get general ItemContainer type for WPF ItemsControl

拟墨画扇 提交于 2019-12-23 10:17:56
问题 I want to determine ItemContainer type from an existing ItemsControl object. var item = control as ItemsControl; //HOW to get child container Type? Example how blend does this: Blend somehow determines that current TabControl type child item is TabItem . How to do same thing in code? 回答1: There is a StyleTypedPropertyAttribute on most classes derived from ItemsControl . Get the one having Property equals to "ItemContainerStyle" . The StyleTargetType property on this attribute should give you

Using uniformgrid to arrange buttons in a square

限于喜欢 提交于 2019-12-23 09:56:13
问题 Im writing this childrens game (memory) and have a list of tiles (List) which i bind to an items control inside a wrappanel. Right now i have 22 tiles and they arrange themselves in two rows in the center. What i really want is to arrange it in a 5x5 matrix in the center of the screen, so it scales with the amount of tiles. I cant get the tiles to show properly, when using the uniform grid, the size is very small and in the top left corner of my screen. When i set the columns and the rows

Access UniformGrid ItemTemplate programmatically

▼魔方 西西 提交于 2019-12-23 03:33:19
问题 I'm trying to build a bingo game simulator using WPF to learn more about WPF, and I'm having trouble figuring out how to change an <ItemsControl> template programmatically. I'm only using the default WPF Application from VS 2010, so I have a MainWindow.xaml, App.xaml and MainWindow.xaml.cs. The reason I want to access the <ItemTemplate> , is to change the bound template if that bingo number comes up as chosen. I've tried this possible solution in my code behind file, but I don't think that

Catastrophic failure in xaml binding

≡放荡痞女 提交于 2019-12-23 02:31:15
问题 I am developing Windows 10 Universal App. I have code below: xaml: <Page x:Class="MyProject.BlankPage1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyProject" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <ItemsControl ItemsSource="{Binding}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate>

WPF ContextMenu using ItemsControl, incorrectly highlight the whole collection

倾然丶 夕夏残阳落幕 提交于 2019-12-23 01:52:08
问题 I need to design one ContextMenu which includes one MenuItem , this MenuItem has a deeper level menu list which binds to a property of type ObservableCollection from my ViewModel. The code looks like this: <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}" > ... <MenuItem Header="Map to account" > <ItemsControl ItemsSource="{Binding RelatedAccounts}" > <ItemsControl.ItemTemplate> <DataTemplate> <MenuItem Header="{Binding Number}" Command="

How to reliably detect when an item is scrolled outside of view?

倖福魔咒の 提交于 2019-12-23 01:12:11
问题 I have a large collection of items bound to a ListBox , with a VirtualizingStackPanel set as its ItemsPanel . As the user scrolls and item containers are created, I do some work to populate the item with data (using a database query). If the user scrolls very rapidly, it builds up a large number of requests that tend to bog things down. What I would like to do is detect when the item is scrolled outside of the viewport, so I can cancel its corresponding request. Here are the approaches I've

WPF Drag-to-scroll doesn't work correctly

泄露秘密 提交于 2019-12-22 11:33:58
问题 I am tying to realize a drag-to-scroll functionality in my application and have problems on my way. Can anybody help me? I have a ScrollViewer and inside it an ItemsControl and within ItemsTemplate I have a UserControl. I want to drag that UserControl within ItemsControl. I want the ScrollViewer to scroll down, when I am dragging to the boundaries of the ItemsControl. protected override void OnPreviewMouseMove(System.Windows.Input.MouseEventArgs e) { if (this.IsMouseCaptured) { // Get the new