itemssource

Set ItemsSource of Control to another control's ItemsSource that is Static and set in Xaml

左心房为你撑大大i 提交于 2019-12-03 16:40:46
I am building a UWP Windows 10 App. In a Page I have a FlipView that has static items. Instead of binding them to an ItemsSource, it was easier to set them in Xaml as: <FlipView x:Name="myFlipView"> <FlipViewItem>...</FlipViewItem> <FlipViewItem>...</FlipViewItem> </FlipView> I want to add an Indicators Control to this FlipView as in this tutorial: http://blog.jerrynixon.com/2014/04/lets-code-build-your-own-flipview-page.html When I want to set the ItemsSource of my <ItemsControl x:Name="Indicators"> I want to set it to the FlipView's ItemsSource. I tried setting it in code as Indicators

WPF TreeView hierarchical binding.

若如初见. 提交于 2019-12-03 09:06:47
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 { get; set; } public List<Folder> Folders { get; set; } public ObservableCollection<Module> Modules { get;

WPF - Bound treeview not updating root items

[亡魂溺海] 提交于 2019-12-02 15:21:56
问题 I'm using a WPF TreeView control, which I've bound to a simple tree structure based on ObservableCollections. Here's the XAML: <TreeView Name="tree" Grid.Row="0"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"> <TextBlock Text="{Binding Path=Text}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> And the tree structure: public class Node : IEnumerable { private string text; private ObservableCollection<Node> children; public string

How to load ItemsSource before setting SelectedItem in ListView?

[亡魂溺海] 提交于 2019-12-02 05:11:57
I have a MVVM page that contains a ListView . I bind ItemSource and SelectedValue , but first time it calls converter for SelectedValue then loads ItemSource . <ListView x:Name="ListViewSurahs" ItemsSource="{Binding MyItems}" FlowDirection="LeftToRight" Grid.Column="2" Grid.Row="4" VerticalAlignment="Top" HorizontalAlignment="Left" HorizontalContentAlignment="Center" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Auto" DisplayMemberPath="Name" SelectedValuePath="ID" SelectedValue="{Binding Source={StaticResource CurrentInfo}, Path=Instance.ID,Mode=OneWay}"

WPF - Bound treeview not updating root items

五迷三道 提交于 2019-12-02 03:25:32
I'm using a WPF TreeView control, which I've bound to a simple tree structure based on ObservableCollections. Here's the XAML: <TreeView Name="tree" Grid.Row="0"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"> <TextBlock Text="{Binding Path=Text}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> And the tree structure: public class Node : IEnumerable { private string text; private ObservableCollection<Node> children; public string Text { get { return text; } } public ObservableCollection<Node> Children { get { return children; } }

WPF: How do I hook into a ListView's ItemsSource CollectionChanged notification?

大城市里の小女人 提交于 2019-12-01 19:31:36
I have a ListView that is databound to an ObservableCollection ... <ListView x:Name="List1" ItemsSource="{Binding MyList}" /> I can't seem to find any event that are triggered when the collection changes, so I'm thinking that somehow I need to hook into the collectionchanged notification somehow? I'm not really sure how to do that. Basically, when the collection changes I want to do additional work beyond what the ListView already does in updating it's list. m-y By default the ItemsSource is of type IEnumerable . You need to first cast to a type that has access to the CollectionChanged event,

WPF DataGrid cannot Add a row when datasource is empty

北慕城南 提交于 2019-12-01 16:08:29
CanUserAddRows="True" only 'works' when there's already data in the ItemsSource of the DataGrid . If it just so happens that there are no rows in the original list of items, then the DataGrid doesn't display a placeholder row for entering new items, even though I've set CanUserAddRows="True" . Why?! Thanks in advance, Trindaz This seem to be a known issue with WPF DataGrid. See discussion here (starting from the 4th comment) Also it seem to be fixed in .net 4. I've made some tests for this issue on 3.5 and 4 (beta2) frameworks. Pls, see results below: First I defined 3 types of item

WPF binding to a collection of ViewModels fails to display as expected

馋奶兔 提交于 2019-12-01 14:15:52
My colleague and I have been desperately trying to understand why we can't get a collection of ViewModels to render as expected. We have created a very simple example that demonstrates the issue. Basically, we have a StupidPerson class that has a Name and a List of friends (also StupidPerson's). In the MainViewModel we create the root StupidPerson and add to his friends four other StupidPerson's. The MainWindow simply displays the source StupidPerson using the StupidPersonViewModel. The StupidPersonViewModel has all the bells and whistles and the code behind the StupidPersonView even

Set ItemsSource of a ComboBox to an Array of Integers?

邮差的信 提交于 2019-12-01 06:36:23
问题 Set ItemsSource of a ComboBox to an Array of Integers? 回答1: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"> <Window.Resources> <x:Array x:Key="Integers" Type="{x:Type sys:Int32}"> <sys:Int32>0</sys:Int32> <sys:Int32>1</sys:Int32> <sys:Int32>2</sys:Int32> </x:Array> </Window.Resources> <ComboBox ItemsSource="{Binding Source={StaticResource Integers}}" /> </Window

Need SIMPLE working example of setting WPF MVVM ComboBox ItemsSource based on SelectedValue of second ComboBox

流过昼夜 提交于 2019-12-01 05:32:38
Can anyone show me a simple working example for a WPF MVVM application to set the ItemsSource of combobox B based on the SelectedItem of ComboBox A? It seems from what I've found on this site that it gets all too complicated all too quickly. What's the "right" MVVM way to get it done? Thank you. EDIT I updated using Didier's example. An extract of my XAML: <ComboBox Name="BrowserStackDesktopOS" ItemsSource="Binding Platforms.AvailableBrowserStackDesktopOSes}" SelectedIndex="0" SelectedItem="{Binding Platforms.BrowserStackDesktopOSSelectedValue, Mode=TwoWay}"/> <ComboBox Name=