XAML DATA BINDING LISTVIEW PROBLEM

Hi all,
I am having a problem binding data to a listview with three objects per item.  I have a static image, and two textboxes one a top the other.  I am getting the following error....

Error: BindingExpression path error: 'Name' property not found on 'Char16'. BindingExpression: Path='Name' DataItem='Char16'; target element is 'Windows.UI.Xaml.Controls.TextBlock' (Name='null'); target property is 'Text' (type 'String')

'My XAML......
<Page
    x:Class="RuSafeWP.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:RuSafeWP"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" Height="665.756">
    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton x:Name="btnADD" Icon="Add" Label="Add"/>
            <AppBarButton x:Name="btnDelete" Icon="Delete" Label="Delete"/>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid RequestedTheme="Light" Background="White" RenderTransformOrigin="0.473,0.725" HorizontalAlignment="Left" Margin="0,0,0,-0.167" Width="400">
        <Grid.RowDefinitions>
            <RowDefinition Height="18*"/>
            <RowDefinition Height="11*"/>
        </Grid.RowDefinitions>
        <Image x:Name="imgMAIN" HorizontalAlignment="Left" Height="100" Margin="50,68,0,0" VerticalAlignment="Top" Width="295" Source="Assets/RuSafe Splash.png"/>
        <TextBlock x:Name="txtVERSION" HorizontalAlignment="Left" Margin="243,10,0,0" TextWrapping="Wrap" Text="Version: " VerticalAlignment="Top" Width="147" RequestedTheme="Dark" Foreground="#FF000108" FontSize="14"/>
        <TextBlock x:Name="OutputTextBlock" HorizontalAlignment="Left" Margin="50,35,0,350.333" TextWrapping="Wrap" Text="TextBlock" Width="295"/>
        <ListView x:Name="lvRUSAFE_FILES" 
                  HorizontalAlignment="Left" 
                  Height="401" 
                  Margin="10,195,0,0" 
                  VerticalAlignment="Top" 
                  Width="380" 
                  Grid.RowSpan="2"
                  ItemsSource="{Binding}"
                  DataContext="RSCatalogs"
                  >

            <ListView.ItemTemplate>
                <DataTemplate>

                <StackPanel Orientation="Horizontal" Height="75">
                    <Image Source="/Assets/stock_lock.png" Height="73" Width="73"/>

                <StackPanel Width="370">
                     <TextBlock Text="{Binding Name}"
                     Foreground="#FFC8AB14" FontSize="28" FontWeight="Bold" />

                    <TextBlock Text="{Binding DTLW}"
                     TextWrapping="Wrap" FontSize="18" />
                </StackPanel>
            </StackPanel>

                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Page>

Open in new window


'My Code Behind
Dim local As StorageFolder = PARENT_PATH

        If local IsNot Nothing Then
            Try
                ' Get the DataFolder folder.

                Dim dataFolder = Await local.GetFolderAsync("RuSafe")
                Dim files = dataFolder.GetFilesAsync()
                Dim _RC As RSCatalogs = Nothing

                ' Get the file.

                For Each file As StorageFile In Await dataFolder.GetFilesAsync()
                    _RC = New RSCatalogs() With { _
                    .Name = file.Name, _
                    .DTLW = "01/02/2014" _
                    }

                Next

                lvRUSAFE_FILES.DataContext = _RC

            Catch ex As Exception

            End Try
        End If

Open in new window

LVL 4
Thunder724Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Thunder724Author Commented:
UPDATE:

I put the name for the controls in my XAML and still got the same error....

Error: BindingExpression path error: 'Name' property not found on 'Char16'. BindingExpression: Path='Name' DataItem='Char16'; target element is 'Windows.UI.Xaml.Controls.TextBlock' (Name='Name'); target property is 'Text' (type 'String')
0
Thunder724Author Commented:
UPDATE:
Here is my collection class.. Perhaps this is the problem.

Public Class RSCatalogs
    Implements System.ComponentModel.INotifyPropertyChanged

    Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Protected Overridable Sub OnPropertyChanged(ByVal propertyName As String)
        RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
    End Sub

    Private m_Name As String
    Private m_DTLW As String

    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set(value As String)
            m_Name = value
        End Set
    End Property

    Public Property DTLW() As String
        Get
            Return m_DTLW
        End Get
        Set(value As String)
            m_DTLW = value
        End Set
    End Property


End Class

Open in new window

0
MikeTooleCommented:
You've set the DataContext on the ListView twice, once in code-behind and the second time, in xaml, to a String object, rather than to an instance of your ViewModel class:
                  DataContext="RSCatalogs"
That's why it can't find the Name property on the Char16 object.

Remove the xaml setting of the DataContext. All you need is:
ItemsSource="{Binding RSCatalogs}"
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Thunder724Author Commented:
Nope, I get nothing back. Below is the Error Output....

Error: BindingExpression path error: 'RSCatalogs' property not found on 'RuSafeWP.RSCatalogs, RuSafeWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. BindingExpression: Path='RSCatalogs' DataItem='RuSafeWP.RSCatalogs, RuSafeWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Windows.UI.Xaml.Controls.ListView' (Name='lvRUSAFE_FILES'); target property is 'ItemsSource' (type 'Object')

Open in new window

0
MikeTooleCommented:
OK, it's an improvement on binding to the string :-)
This is now saying that it can't find an RSCatalogs property on the RSCatalogs object instance
- Which makes sense, RScatalogs is set as the DataContext in code behind.
Switch back to ...
ItemsSource="{Binding}"
That should do the trick.
0
Thunder724Author Commented:
OK I got no Error outputs; but no data showing up either.
I put a message box in the code behind to make sure that file.name was returned.  There is one file so far.  Do you think there maybe something wrong with my object class _RC?
0
Thunder724Author Commented:
Update:
I can see that the _RC class has data contained within it; so at least I know that the class seems to be working; just don't understand why i'm not seeing anything on the pages listview.
0
MikeTooleCommented:
I've been approaching this bit-by-bit, looking for obvious errors - which is the nature of this site.
So here's the next one, where is the collection property that you're binding to?
RSCatalogs is a single instance of something - to drive the list you need a collection property returning either a List<MyInstanceClass> or an ObservableCollection<MyInstanceClass>
I don't see that anywhere.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thunder724Author Commented:
Yes you are correct.  I'm not sure how to implement that; i'm thinking that is my problem too.
0
Thunder724Author Commented:
I got it to work.
Thanks you so much for you help.
I created a collection and bound the context to it.
0
MikeTooleCommented:
Have separate classes for the Instance and collection. In the iteration ...
                For Each file As StorageFile In Await dataFolder.GetFilesAsync()
... add each instance to the List<MyClass> in the collection class.
Bind the Listbox to the collection class instance
0
Thunder724Author Commented:
Yup, that's what I did.
Thanks very much again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.