Click here to Skip to main content
15,895,827 members

wpf data binding: where i am going wrong? please help

Manu_vish asked:

Open original thread
i am trying wpf for the first time and with lot of research and help from Pete O'Hanlon. i was able to come to a certain point. but after binding with the class and all i am still not able to get the value to the label when it changes in the code of class

I am using VS2008 framework 3.5

XML
<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Avenet Prduct Description Extractor" Height="396.627" Width="588.123" removed="AliceBlue" >
    <Grid Height="341.077" Width="567.721" removed="AliceBlue">

        
        <StackPanel Margin="170.225,226.418,3.143,0" Name="StackPanel1" Height="97.994" VerticalAlignment="Top">
            <Label Height="30.906" Name="lblCrntSt1" Content="{Binding PrdFrstName}" Width="161" BorderThickness="2" BorderBrush="AliceBlue" Background="Red" Foreground="White" FontSize="13"></Label>
            <Label Height="33.633" Name="lblcrntst2" Content="{Binding prdScndName}" Width="161" BorderThickness="2" BorderBrush="AliceBlue" Background="Red" Foreground="White" FontSize="13"></Label>
            <Label Height="29.997" Name="lblcrntst3" Content="{Binding prdLastName}" Width="161" BorderThickness="2" BorderBrush="AliceBlue" Background="Red" Foreground="White" FontSize="13">Label State3</Label>
        </StackPanel>
        <StackPanel Margin="0,62.216,73.348,0" Name="StackPanel2" Height="94.816" VerticalAlignment="Top" removed="Honeydew" HorizontalAlignment="Right" Width="144.43">
            <StackPanel.Resources>
                <Style TargetType="Button">
                    <Setter Property="Margin" Value="0,07,0,0"></Setter>

                </Style>

            </StackPanel.Resources>
            
        
    </Grid>
</Window>



here is the window class where it is initialized

VB
Class Window1

    Dim clsIniti As New ExtractDetails

Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        'clsIniti = New ExtractDetails
        Me.DataContext = clsIniti

        ' Add any initialization after the InitializeComponent() call.

    End Sub
end class




here is my class where it all happens. this is a separate class

VB
Public Class ExtractDetails
    Inherits UserControl
    Implements System.ComponentModel.INotifyPropertyChanged

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    
    Private _prdFrstName, _prdScndName, _prdLastName As String
    Private lstPdfDwn As List(Of String) = New List(Of String)
    Dim intPgeLop As Integer = 0
    Dim blnPgeLod As Boolean


#Region "Properties for Passing back the values to form"
     Public Property PrdFrstName() As String
        Get
            Return _prdFrstName
        End Get
        Set(ByVal value As String)
            If _prdFrstName <> value Then
                _prdFrstName = value
                OnPropertyChanged("PrdFrstName")
            End If
        End Set
    End Property



    Public Property prdScndName() As String
        Get
            Return _prdScndName
        End Get
        Set(ByVal value As String)
            If _prdScndName <> value Then
                _prdScndName = value
                OnPropertyChanged("prdScndName")
            End If
        End Set
    End Property

    Public Property prdLastName() As String
        Get
            Return _prdLastName
        End Get
        Set(ByVal value As String)
            If _prdLastName <> value Then
                _prdLastName = value
                OnPropertyChanged("prdLastName")
            End If
        End Set
    End Property

	Private Sub OnPropertyChanged(ByVal propertyName As String)
        	RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
    	End Sub

#End Region


 Public Sub suMainStrt(ByVal strFilePath As String)
		PrdFrstName= "http://www.lg.com"

                Call extract(webBrwFrst, strComurl(1))
                webBrwFrst.Dispose()
                webBrwFrst = Nothing
end sub

End Class



I m getting confused. please correct me. i am totally new to this WPF and MVVM
the extract function is working and i am getting all the details and every thing
i created this in windows forms and it is working great.

this is edited coed and i might have missed adding something. but i am not getting any errors as of such in my VS2008
Tags: Visual Basic, WPF

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900