compositecollection

Dynamically binding and statically adding MenuItems - using view Models/MVVM

隐身守侯 提交于 2020-05-14 07:36:08
问题 I'm trying to have a dynamic menu item using MVVM from an observable collection. Everything worked, but then I needed to add a "add new" button to the end. I found a solution using a CompositeCollection, like here: How do I dynamically bind and statically add MenuItems? So have the following code, where TimeSpans is a collection of ViewModels: <MenuItem Header="Time Ranges"> <MenuItem.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding TimeSpans}" /> <Separator />

XAML binding to CompositeCollection

不想你离开。 提交于 2020-02-15 06:41:12
问题 I have only one datagrid in a single view but the collections which are ItemsSource's of this datagrid are in different View Models. So is it possible to bind this single datagrid in view with the collections in two different View Models? For each row in the grid, display an item from one collection, and an item from the other collection..! to display all columns in one row. xaml: DataContext="{DynamicResource ViewModelCombine}"> <Window.Resources> <vm:ViewModelCombine x:Key="ViewModelCombine

Binding/Triggering “Select all”-CheckBox ComboBoxItem in WPF

老子叫甜甜 提交于 2019-12-23 04:43:53
问题 I'm trying to make a WPF CustomControl CheckComboBox with a "Select All" item in addition to a user defined list of items. When "Select All" is selected, all items in the list should be checked accordingly. How can I act to the "Select All" item being clicked? I have tried a lot of things, but the property "SelectAll" in the CheckComboBox.cs is never entered. This is my current code. Generic.xaml <Style TargetType="{x:Type local:CheckComboBox}"> <Setter Property="Template"> <Setter.Value>

How to handle a CompositeCollection with CollectionView features?

匆匆过客 提交于 2019-12-19 07:28:31
问题 Is there a way to get notified when CompositeCollection's current location changes? I need to have the CompositeCollection monitored by a CollectionView, any ideas are welcommed. 回答1: You can detect when the current item has changed by monitoring the ICollectionView.CurrentChanged event of your CollectionView. The following code works for me: CompositeCollection cc = new CompositeCollection(); cc.Add(new CollectionContainer { Collection = new string[] { "Oh No!", "Fie" } }); cc.Add(new

How to add option “All” to a combobox in WPF with binding from Database

十年热恋 提交于 2019-12-19 03:22:58
问题 I have the following ComboBox in WPF. I know that I can add option ALL with CompositeCollection, but I don't know how. It would be great if somebody help me out with a short tutorial. <ComboBox SelectionChanged="ComboBoxOperatingPoints_SelectionChanged" x:Name="ComboBoxOperatingPoints" DropDownOpened="ComboBoxOperatingPoints_DropDownOpened_1" FontSize="30" HorizontalAlignment="Right" Margin="40,40,0,0" VerticalAlignment="Top" Width="200" Height="50" IsSynchronizedWithCurrentItem="True"

WPF Binding a MenuItem in a CompositeCollection not working

自作多情 提交于 2019-12-12 13:26:05
问题 I'm having problems binding a command to a menuitem in a compositecollection. The MenuItem is part of ContextMenu which is defined in the UserControl.Resources . The problem is that the binding of the New label is not working. When I place the MenuItem outside of the composite collection it will work. Any ideas? <UserControl.Resources> <ContextMenu x:Key="DataGridRowContextMenu"> <MenuItem Header=" Set label"/> <MenuItem.ItemsSource> <CompositeCollection> <CollectionContainer Collection="

Merging two ObservableCollection and Bind Datagrid with this MergedCollection as source using CompositeCollection

你说的曾经没有我的故事 提交于 2019-12-12 03:05:58
问题 .Xaml DataContext="{DynamicResource ViewModelCombine}"> <Window.Resources> <vm:ViewModelCombine x:Key="ViewModelCombine"/> </Window.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <DataGrid x:Name="grd"> <DataGrid.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Source={StaticResource ViewModelCombine}, Path=MergedSource}"/> </CompositeCollection> </DataGrid.ItemsSource> <DataGrid.Columns> <DataGridTextColumn Header=

Any idea on how to sort a CompositeCollection?

徘徊边缘 提交于 2019-12-11 04:59:11
问题 I have a CompositeCollection that consists of ObservableCollections of two types: Companies and Contacts. Contact has a property FullName while Company has a property Name. I want to apply sorting so the collections are mixed by their types but sorted by their name, example: Itzhak Perlman John Doe Microsoft Sarah Moore StackOverflow Walter Richardson Note that I bound the ItemsControl to a CollectionViewSource that its Source is set the CompositeCollection, it's view becomes a

How do I convert a ComboBox to use a bound CompositeCollection?

北战南征 提交于 2019-12-04 02:06:38
问题 I have a ComboBox that has a bound items source... I've stripped my example down to the key pieces: <UserControl x.Class="My.Application.ClientControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conv="clr-namespace:My.Utilities.Converters" Name="ClientControl"> <UserControl.Resources> <ResourceDictionary> <CollectionViewSource Key="x:ClientsCollection" /> </ResourceDictionary> <conv:ClientOptions x:Key=

How do I convert a ComboBox to use a bound CompositeCollection?

雨燕双飞 提交于 2019-12-01 13:40:08
I have a ComboBox that has a bound items source... I've stripped my example down to the key pieces: <UserControl x.Class="My.Application.ClientControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conv="clr-namespace:My.Utilities.Converters" Name="ClientControl"> <UserControl.Resources> <ResourceDictionary> <CollectionViewSource Key="x:ClientsCollection" /> </ResourceDictionary> <conv:ClientOptions x:Key="ClientOptions" /> </UserControl.Resources> ... <ComboBox Name="Options" DataContext="ClientsCollection"