Click here to Skip to main content
15,559,567 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
Mycroft Holmes9-Sep-12 15:25
professionalMycroft Holmes9-Sep-12 15:25 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
Pete O'Hanlon10-Sep-12 6:03
mvaPete O'Hanlon10-Sep-12 6:03 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
Abhinav S10-Sep-12 17:14
Abhinav S10-Sep-12 17:14 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
_Maxxx_29-Oct-12 18:30
professional_Maxxx_29-Oct-12 18:30 
QuestionTuple as a Binding Parameter Pin
Ahrimal6-Sep-12 23:11
Ahrimal6-Sep-12 23:11 
QuestionBinding to an XML list of attributes Pin
Jayme656-Sep-12 12:46
Jayme656-Sep-12 12:46 
AnswerRe: Binding to an XML list of attributes Pin
Pete O'Hanlon6-Sep-12 23:24
mvaPete O'Hanlon6-Sep-12 23:24 
GeneralRe: Binding to an XML list of attributes Pin
Jayme657-Sep-12 7:11
Jayme657-Sep-12 7:11 
Thanks for your reply!!
I think that I'd better expose the whole code.

XML file:
XML
<Emulators>
    <System>
        <Gear>Name1</Gear>
        <Kind name="att1"/>
        <Kind name="att2"/>
        <Kind name="att3"/>
    </System>
</Emulators>


VB code:
VB
Class MainWindow
    Dim data As XmlDataProvider = New XmlDataProvider()
    Private Sub MainWindow_Initialized(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Initialized
        data.Source = New Uri(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\myapplication\Systems.xml")
        data.XPath = "Emulators/System"
        Grid1.DataContext = data
    End Sub
End Class


XAML code:
XML
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication1"         
    Title="MainWindow" Height="350" Width="525" Background="#FF4E4E64">
    <Grid Name="Grid1">
        <Grid.Resources>
            <DataTemplate x:Key="KindTemplate">
                <TextBlock Text="{Binding XPath=@name}" />
            </DataTemplate>
        </Grid.Resources>
        <TextBox Text="{Binding XPath=Gear, UpdateSourceTrigger=PropertyChanged}" Height="23" HorizontalAlignment="Left" Margin="197,230,0,0" Name="TextBox3" VerticalAlignment="Top" Width="220" />
        <ListBox ItemsSource="{Binding Source=data, XPath=//Kind}" ItemTemplate="{StaticResource KindTemplate}" Margin="261,51,12,149" />
        </Grid>
</Window>


It doesn't work, I get a
System.Windows.Data Error: 44 : BindingExpression with XPath cannot bind to non-XML object.; XPath='//Kind' BindingExpression:Path=; DataItem='String' (HashCode=2037252866); target element is 'ListBox' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') data


modified 7-Sep-12 13:08pm.

GeneralRe: Binding to an XML list of attributes Pin
Pete O'Hanlon7-Sep-12 7:52
mvaPete O'Hanlon7-Sep-12 7:52 
GeneralRe: Binding to an XML list of attributes Pin
Jayme657-Sep-12 8:10
Jayme657-Sep-12 8:10 
GeneralRe: Binding to an XML list of attributes Pin
dbaseman7-Sep-12 22:06
dbaseman7-Sep-12 22:06 
GeneralRe: Binding to an XML list of attributes Pin
Jayme658-Sep-12 1:32
Jayme658-Sep-12 1:32 
GeneralRe: Binding to an XML list of attributes Pin
dbaseman8-Sep-12 11:08
dbaseman8-Sep-12 11:08 
GeneralRe: Binding to an XML list of attributes Pin
Jayme659-Sep-12 1:04
Jayme659-Sep-12 1:04 
GeneralRe: Binding to an XML list of attributes Pin
dbaseman9-Sep-12 17:18
dbaseman9-Sep-12 17:18 
QuestionHow to implement a gallery like the built-in gallery in Windows Phone Pin
small25-Sep-12 17:22
small25-Sep-12 17:22 
GeneralRe: How to implement a gallery like the built-in gallery in Windows Phone Pin
small29-Sep-12 16:19
small29-Sep-12 16:19 
QuestionSet background of TreeViewItem within HierarchicalDataTemplate with converter Pin
toengi19824-Sep-12 21:19
toengi19824-Sep-12 21:19 
AnswerRe: Set background of TreeViewItem within HierarchicalDataTemplate with converter Pin
Wayne Gaylard4-Sep-12 22:57
professionalWayne Gaylard4-Sep-12 22:57 
SuggestionRe: Set background of TreeViewItem within HierarchicalDataTemplate with converter Pin
toengi19824-Sep-12 23:03
toengi19824-Sep-12 23:03 
GeneralRe: Set background of TreeViewItem within HierarchicalDataTemplate with converter Pin
Wayne Gaylard4-Sep-12 23:11
professionalWayne Gaylard4-Sep-12 23:11 
SuggestionRe: Set background of TreeViewItem within HierarchicalDataTemplate with converter Pin
Mycroft Holmes5-Sep-12 13:52
professionalMycroft Holmes5-Sep-12 13:52 
QuestionCommandParameter is null when opening a ContextMenu Pin
AlexZieg713-Sep-12 23:57
AlexZieg713-Sep-12 23:57 
QuestionReuse template for different listbox items Pin
LionAM3-Sep-12 6:09
LionAM3-Sep-12 6:09 
Questiontreeview that has a custom treeview that consists of a button and a textbox Pin
truel3-Sep-12 5:48
truel3-Sep-12 5:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.