itemssource

ItemsSource and collections in which only element properties change

女生的网名这么多〃 提交于 2019-12-13 03:36:45
问题 I'm having grief with a ComboBox not reflecting changes in the properties of the collection to which its ItemsSource is bound. There is a tree made up of a Categories observable collection of Category objects containing Setting objects. Some settings define the presentation names for the domain of values permitted for other settings. These are spread over several categories, but a little magic with LINQ produces an ObservableCollection in which ChannelCategory exposes properties ChannelNumber

How to use RelativeSource Binding to create DataGrid binding to Model and ViewModel?

别来无恙 提交于 2019-12-12 13:24:03
问题 I have a DataGrid which has a DataGridTemplateColumn that uses the ItemsSource binding of the DataGrid, but in the ComboBox of the DataGridTemplateColumn, I want to be able to bind to the ViewModel for the View instead of the ItemsSource. <DataGrid ItemsSource="{Binding ModelValues, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" > <DataGridTemplateColumn Header="myHeader" Width="200"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox DisplayMemberPath="Value"

WPF ListBox with multiple sources of different types

Deadly 提交于 2019-12-12 04:47:08
问题 I was actually setting up a sample application for something entirely different, but then I was trying this: I have a collection of Movies . I'll have a list box which displays all the movies. The list box, however, provides them as buttons, so that you can click onto a button and play the movie. The code is: <StackPanel DockPanel.Dock="Top"> <ListBox ItemsSource="{Binding Movies}" SelectedItem="{Binding Path=SelectedMovie}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost=

WPF DataGridComboBoxColumn different ItemsSource for a specific row

帅比萌擦擦* 提交于 2019-12-12 03:53:09
问题 I am trying to give a new ItemsSource to a DataGridComboBoxColumn in a specific row in my program when the selection of an other DataGridComboBoxColumn in the same row is changed. The problem is that I am only able to change the ItemsSource of all rows at the same time. Is it possible to give a specific ItemsSource for a DataGridComboBoxColumn to only one row in a Datagrid ? This is the declaration of my DataGrid and my DataGridComboBoxColumn <DataGrid Name="DATAGRIDSEARCH"

WPF: Binding a ItemsSource to a Directory

流过昼夜 提交于 2019-12-11 10:43:23
问题 I'm trying to do my first WPF project, and I've started with this sample project for image display. Part of it is the XAML that binds a Listbox to an Array of images: <ListBox.ItemsSource> <x:Array Type="{x:Type ImageSource}"> <ImageSource>http://static.flickr.com/34/70703587_b35cf6d9eb.jpg</ImageSource> <ImageSource>http://static.flickr.com/20/70703557_494d721b23.jpg</ImageSource> <ImageSource>http://static.flickr.com/35/70703504_3ebf8f0150.jpg</ImageSource> <ImageSource>http://static.flickr

WPF - reset ListBox scroll position when ItemsSource changes

╄→尐↘猪︶ㄣ 提交于 2019-12-09 14:10:57
问题 I currently have a ListBox whose ItemsSource collection is bound to a property on my viewmodel, of type IEnumerable. When that preoprty's reference changes, the ListBox updates as expected, however I have a problem in that if I have a large collection of items and scroll to the bottom of the ListBox, and then change the reference to another collection containing, say, 1 item, the ListBox view is blank and no scrollbar is displayed. I have to then scroll the listbox up with the mouse wheel,

WPF TreeView hierarchical binding.

寵の児 提交于 2019-12-09 06:54:15
问题 just starting with wpf. I need to bind the object (Hierarchical) Folder public class Folder { public Folder() { this.Name = string.Empty; this.Modules = new ObservableCollection<Module>(); this.Folders = new List<Folder>(); this.HasChild = false; } public Folder(Folder parent) { this.Name = string.Empty; this.Modules = new ObservableCollection<Module>(); this.Folders = new List<Folder>(); this.HasChild = false; this.Parent = parent; } public bool HasChild { get; set; } public string Name {

WPF: Setting ItemSource in XAML vs. code-behind

情到浓时终转凉″ 提交于 2019-12-09 03:14:07
问题 Since this is WPF, it may look like lots of code, but don't be frightened, the question is really simple! I have the following XAML: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:hax="clr-namespace:hax" x:Class="hax.MainWindow" x:Name="Window" Title="Haxalot" Width="640" Height="280"> <Grid x:Name="LayoutRoot"> <ListView ItemsSource="{Binding AllRoles}" Name="Hello"> <ListView.View> <GridView>

IEnumerable property without type

China☆狼群 提交于 2019-12-06 20:39:08
问题 I'm trying to make a property like the official DataGrid.ItemsSource, from MSDN: public IEnumerable ItemsSource { get; set; } This provides the support of any type, in any derived class. With this, I can set something like var list = new List<ObservableCollection<KeyValuePair<decimal, bool>>>(); MyDataGrid.ItemsSource = list; But when I try to make a property of an IEnumerable without the Type T, exactly as MSDN says, I get an error on VisualStudio: Using the generic type 'System.Collections

Show if ItemsControl.ItemsSource is null

夙愿已清 提交于 2019-12-06 03:06:59
问题 Greetings, I have a ItemsControl which template I changed to show a RadioButton for every object in the binded ItemsSource. However the ItemsSource can be empty and when it is empty I'd like to show a default value. Something like "The binded list contains no items for you to select"... One way I thought of is to set the ItemsControl.Visibility to Collapsed and have a TextBlock.Vsibility to Visible which shows the text.. But this would include a lot more data. Is it possible to show a default