itemscontrol

wpf using grid as itemshost stacking multiple items in single 'cell' automatically

我怕爱的太早我们不能终老 提交于 2019-12-11 03:07:43
问题 I am binding an items control to a datasource and using a grid as my itemshost. I wish to have the items locate themselves into the correct cell in the grid (I can do this), and also stack themselves so they are not all on top of each other (I can't figure out how to insert the items into a stackpanel or other panel in the grid). here is the .cs file for the two classes: public class listofdata { public List<data> stuff { get; set; } public listofdata() { stuff = new List<data>(); stuff.Add

Using ICustomTypeDescriptor with an ItemsControl

柔情痞子 提交于 2019-12-11 02:51:29
问题 I'm implementing ICustomTypeDescriptor so that I can create types with dynamic properties at runtime, however, instead of using the ICustomTypeDescriptor with a DataGrid which is how most people seem to use it, I'm wanting to use it with an ItemsControl. Below is the guts of the application. (sorry, it's a lot of code) public class BindableTypeDescriptor : INotifyPropertyChanged, ICustomTypeDescriptor { public event PropertyChangedEventHandler PropertyChanged; protected virtual void

Excel like drag selection in Wpf itemscontrol

浪尽此生 提交于 2019-12-10 23:07:17
问题 I am looking to make a selection rectangle in Wpf items control just as in MS Excel.I have looked at decorators and adoners but got little help.I need the thick border around the cells that i select using mouse(check screenShot) 回答1: I have a solution for you, that seems to work fairly well with just an attached property for you to attach to an items control such as a listbox. The code makes guesses as to whether or not selected items are contiguous by just checking that they are contiguous

Silverlight: Set Items Widths in ItemsControl to Stretch

随声附和 提交于 2019-12-10 21:49:51
问题 I've got an ItemsControl which fills from top to bottom, but I can't get it's child items to occupy the whole width of the ItemsControl: I basically need to stretch the green bits to fill the width of the control (as shown by the blue bits). I've tried things like setting the HorizontalAlignment property of the template item to Stretch and I've even tried binding it's Width property to the ItemsControl Width, but neither worked. Should be a straight forward one, but it's something I just can

WPF ItemControl: restrict the type of the item to a specific one

牧云@^-^@ 提交于 2019-12-10 19:31:53
问题 I'm creating as an exercise a WPF custom control to display log messages as in the VS panel (Errors/Warnings/Message). The control is an ItemControl, every item is a message to display. But I have to classify the message in the proper category, so I need each item to expose something ( an interface maybe ) to let the control know how to categorizxe the message. I don't know how to force the Item to be of a certain type, how can I achieve this ? Is the design startegy wrong ? Thanks! 回答1: you

Disable WPF TreeView (or TreeViewItem) selection?

吃可爱长大的小学妹 提交于 2019-12-10 16:12:35
问题 Is there a nice way (except retemplating the whole TreeViewItem.Template ) to disable selection in TreeView ? I am basically looking for the ItemsControl style of the TreeView (An ItemsControl is the best use to 'disable' selection on ListBox , read this post) 回答1: Whenever an item is selected, you could "unselect" it. Ex. modify the code from http://www.codeproject.com/KB/WPF/TreeView_SelectionWPF.aspx or use a MVVM approach (see http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx)

Combining ItemsControl with draggable items - Element.parent always null

拈花ヽ惹草 提交于 2019-12-10 03:04:00
问题 I'm binding an ItemsControl with Canvas as ItemsPanelTemplate to an ObservableCollection. I want to make the items draggable using the DraggableExtender as posted in Dragging an image in WPF (I don't want to use transforms - I need to use the Canvas Left and Top properties) It's defined as : <ItemsControl ItemsSource="{Binding Path=Nodes}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas IsItemsHost="True" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate>

ItemsControl, VirtualizingStackPanel and ScrollViewer height

放肆的年华 提交于 2019-12-10 02:52:06
问题 I want to display a important list of items using an ItemsControl. The reason why I'm using an ItemsControl is that the DataTemplate is much more complex in the application I'm working on: The sample code provided only reflects the sizing problem I have. I would like : the ItemsControl to be virtualized because there is many items to display its size to expand to its parent container automatically (the Grid) <Grid> <ItemsControl x:Name="My" ItemsSource="{Binding Path=Names}"> <ItemsControl

Listbox scrollbar thumb changes size when content is variable height

妖精的绣舞 提交于 2019-12-09 00:45:38
问题 I have a ListBox with many objects displayed, each of which can be a variable height, based on the number of values each object has. See my previous question that was answered here. Many objects are 5-lines high, while others are 1. The scroll bar in the ListBox does not appear to like this, probably due to the virtualization. While you scroll through, the thumb on the scroll bar will change its size , based on how many items are actually fitting into the box at that current moment. This

WPF ContextMenu using ItemsControl, incorrectly highlight the whole collection

梦想的初衷 提交于 2019-12-08 20:53:39
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="{Binding PlacementTarget.DataContext.MapToAccountCommand, RelativeSource={RelativeSource AncestorType