itemsource

Filter itemsource

这一生的挚爱 提交于 2020-05-15 08:42:29
问题 With this code I'm setting my Itemsource of my datagrid. However I got more wpf controls that are needed to filter the datagrid even more, for example from a time range. I could write a new query for this but that seems unnecessary as the data is already available, I just need to filter it. But whats the best way to do this? Any help I could get really appreciate! DateTime dateStart = CalenderSearch.SelectedDates.First(); DateTime dateEnd = CalenderSearch.SelectedDates.Last(); ObjectQuery

Can't change gridview itemssource

那年仲夏 提交于 2020-01-17 07:45:55
问题 I'm trying to change a box's color in a gridview(that has ItemTemplates which has 100 green boxes). First, I created a list(which typed as my class) and I added all items to list and I added list to my gridview source : grid1.ItemsSource = boxlist; After, I added a click event for item click on gridview. I want that when I clicked to an item, this item's color will be changed. So I edited list as it : int id = ((Boxes)e.ClickedItem).id; boxlist[id].color = "DarkRed"; grid1.ItemsSource =

in WPF I need to have a collection of a collection of drawing objects

天大地大妈咪最大 提交于 2019-12-31 04:22:07
问题 I have a WPF project that draws several things in a panel. For the next release I need to add another type of thing to draw in addition to the existing things. Currently I have a grid that contains an ItemsControl which contains an ItemsPanel and an ItemsSource. The existing ItemsSource looks something like this: <ItemsControl.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Source={StaticResource MainWindowResource}, Path=DottedLines, Mode=OneWay}"/>

Why does the DataGrid not update when the ItemsSource is changed?

烈酒焚心 提交于 2019-12-17 23:22:19
问题 I have a datagrid in my wpf application and I have a simple problem. I have a generic list and I want to bind this collection to my datagrid data source every time an object is being added to the collection. and I'm not interested to use observable collection. the point is I'm using the same method somewhere else and that works fine. but this time when i press Add button an object is added and datagrid updates correctly but from the second item added to collection datagrid does not update

DataTemplates to display a collection of Points as Ellipses in WPF

半世苍凉 提交于 2019-12-13 16:54:18
问题 In my application, the user is supposed to click over an image, and as he clicks some dots appear. Also he can remove them by right clicking, etc. So I have a test project composed of a single Window (xaml + codebehind) with a canvas, and I am handling some of its events, as MouseMove and MouseLeftButtonDown which are going to add points to an ObservableCollection<Point> in code behind. I already have this, what I don't know is how I'm supposed to implement data-templating and databinding so

How to dynamically add UserControl to ItemsControl?

痴心易碎 提交于 2019-12-11 18:58:58
问题 I have a WPF UserControl which is dynamically created at runtime. Depending on user interaction, from 1-5 of these controls is created and should be added to the UI. I have an ObservableCollection<PlayerSpec> PlayerSpecViews in the xaml.cs code-behind. Initially I tried using a Grid and dynamically adding RowDefinitions but that wasn't working. The control would be scaled down in size. Then I tried using an ItemsControl but the binding was not adding the Control but instead the type name. How

Bind Usercontrol contained in a ObservableCollection<CustomClass> in a WrapPanel

大城市里の小女人 提交于 2019-12-11 09:31:43
问题 I have a class defined this way: public class CustomClass { string Name; int Age; Usercontrol usercontrol; } where Usercontrol is a visual element that I want to insert in a WrapPanel. CustomClass is organized in a static ObservableCollection. public static class CollectionClass { public static ObservableCollection<CustomClass> MyCollection = new ObservableCollection<CustomClass>(); } I am looking to bind the usercontrol property of the CustomClass in the collection to be visualized in the

Add DataGrid checkboxcolumn with different values in different rows

删除回忆录丶 提交于 2019-12-10 19:46:56
问题 I got a DataGrid that is bound to an object PlacementData (PD). PD has a property "P_Unit". public class PlacementData { public bool PIsChecked { get; set; } public string PlacementHeader { get; set; } public string P_NumberOfCases { get; set; } public int P_Value1 { get; set; } public int P_Value2 { get; set; } public int P_Value3 { get; set; } public int P_Value4 { get; set; } public int P_Value5 { get; set; } public string P_Unit { get; set; } } In my DataGrid I added a Combobox in

in WPF I need to have a collection of a collection of drawing objects

只谈情不闲聊 提交于 2019-12-02 05:04:11
I have a WPF project that draws several things in a panel. For the next release I need to add another type of thing to draw in addition to the existing things. Currently I have a grid that contains an ItemsControl which contains an ItemsPanel and an ItemsSource. The existing ItemsSource looks something like this: <ItemsControl.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Source={StaticResource MainWindowResource}, Path=DottedLines, Mode=OneWay}"/> <CollectionContainer Collection="{Binding Source={StaticResource MainWindowResource}, Path=BarrierLines, Mode=OneWay

Why does the DataGrid not update when the ItemsSource is changed?

白昼怎懂夜的黑 提交于 2019-11-28 18:38:26
I have a datagrid in my wpf application and I have a simple problem. I have a generic list and I want to bind this collection to my datagrid data source every time an object is being added to the collection. and I'm not interested to use observable collection. the point is I'm using the same method somewhere else and that works fine. but this time when i press Add button an object is added and datagrid updates correctly but from the second item added to collection datagrid does not update anymore. Here is the Code : private void btnAddItem_Click(object sender, RoutedEventArgs e) {