xmldataprovider

HierarchicalDataTemplate and HeaderedItemsControl with ControlTemplate fails to show nested data

放肆的年华 提交于 2019-12-04 14:14:56
问题 I can get this pattern to work with Menu and TreeView but I must be missing something when I make an attempt with HeaderedItemsControl : <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Page.Resources> <HierarchicalDataTemplate x:Key="MenuItemTemplate" ItemsSource="{Binding XPath=foo}"> <AccessText Text="{Binding XPath=@a}" /> </HierarchicalDataTemplate> <Style

How to select a databound TreeViewItem?

你说的曾经没有我的故事 提交于 2019-12-04 06:23:31
问题 I have a XML databound to a TreeView with a XmlDataProvider. If i add a subnode to the XML the TreeView shows it, but how can i select this item? XAML: <Window.Resources> <HierarchicalDataTemplate DataType="category" ItemsSource="{Binding XPath=child::node()}"> <TextBlock Text="{Binding XPath=@name}" FontWeight="Bold" /> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="card"> <TextBlock Text="{Binding XPath=./title}" FontStyle="Italic" /> </HierarchicalDataTemplate>

How to Bind an XmlDataProvider Class Property to a XAML TreeView

无人久伴 提交于 2019-12-02 18:04:36
问题 I would like to bind a TreeView control I have defined in XAML to a property in its code-behind class. I already read through a WPF Basic Data Binding FAQ, but the example in the comments at the very bottom of the page didn't work when I tried to use an XmlDataProvider as the binding source. How can I modify the following code so that the binding is defined in the XAML, rather than in the class's constructor? In other words, how can I modify the TreeView's ItemsSource attribute to reference a

Numerical string sorting in a listbox

谁说我不能喝 提交于 2019-12-02 14:59:50
问题 I have a ListBox which ItemSource is bound to a CollectionViewSource . The CVS Source is an XmlDataProvider . So the ListBox lists all nodes (name attribute) i specified. Now those nodes have attributes, and i want the ListBox to be sorted by them. The problem is, since the underlying data is xml, every value(attributes of the node) is a string, but some of the values represent numerical values. Since sorting with CollectionViewSource.SortDescriptions.add (...) will sort those (string)values

How to Bind an XmlDataProvider Class Property to a XAML TreeView

自古美人都是妖i 提交于 2019-12-02 10:54:27
I would like to bind a TreeView control I have defined in XAML to a property in its code-behind class. I already read through a WPF Basic Data Binding FAQ , but the example in the comments at the very bottom of the page didn't work when I tried to use an XmlDataProvider as the binding source. How can I modify the following code so that the binding is defined in the XAML, rather than in the class's constructor? In other words, how can I modify the TreeView's ItemsSource attribute to reference a property in its code-behind class? SomeClass.xaml - Works <UserControl x:Class="SomeNamespace

How do I create a new row in WPF DataGrid when it is bound to an XmlDataProvider?

夙愿已清 提交于 2019-11-29 01:40:20
I have a project with an XmlDataProvider bound to a WPF DataGrid control. I have the bindings on the DataGrid set up as follows: <dg:DataGrid ItemsSource="{Binding Source={StaticResource XmlData}, XPath=Root/People/Person}" AutoGenerateColumns="False"> <dg:DataGrid.Columns> <dg:DataGridTextColumn Header="ID" Binding="{Binding XPath=ID}"/> <dg:DataGridTextColumn Header="Name" Binding="{Binding XPath=Name}"/> </dg:DataGrid.Columns> </dg:DataGrid> Users can edit entries using the DataGrid without any problems. What I cannot manage to accomplish is allowing the user to add a new row (i.e. a new

How to bind XmlDataProvider.Source to MVVM property

血红的双手。 提交于 2019-11-28 13:00:57
I've got a treeview bound to an XmlDataProvider following this example . The app I am working on is following the MVVM pattern and the Xml is from a file that the user will open. When I try to bind the Source property of the XmlDataProvider like so <XmlDataProvider Source="{Binding Path=XmlFilePath}"/> I get a "Binding can only be applied to a DependencyProperty of a Dependency object." or somesuch. So short of cobbling the binding together procedurally is there a way to declaratively bind the XmlDataProvider Source ? If I try to forgo the data provider and bind the tree directly to an XmlNode

How to bind XmlDataProvider.Source to MVVM property

喜夏-厌秋 提交于 2019-11-27 07:32:52
问题 I've got a treeview bound to an XmlDataProvider following this example. The app I am working on is following the MVVM pattern and the Xml is from a file that the user will open. When I try to bind the Source property of the XmlDataProvider like so <XmlDataProvider Source="{Binding Path=XmlFilePath}"/> I get a "Binding can only be applied to a DependencyProperty of a Dependency object." or somesuch. So short of cobbling the binding together procedurally is there a way to declaratively bind the