我是新來的WPF和嘗試這樣的事情來更新類中的WPF窗體中的標籤文本。 onChange事件是越來越觸發,但形式wpf標籤文本綁定不工作,我錯了
這裏就沒有得到顯示的是我的課
Public Class ExtractDetails
Inherits UserControl
Implements INotifyPropertyChanged
Private _prdFrstName as string
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Property PrdFrstName() As String
Get
Return _prdFrstName
End Get
Set(ByVal value As String)
If _prdFrstName <> value Then
_prdFrstName = value
Me.OnPropertyChanged("PrdFrstName")
End If
End Set
End Property
Public Sub suMainStrt()
PrdFrstName = strComurl ''contyains teh URL to nagigate to
webBrwFrst = New WebBrowser
webBrwFrst.Navigate(New Uri(strComurl))
Call extract(webBrwFrst, strComurl)
end sub
末級
網址不斷改變,因爲我是個從Excel獲取值文件和循環每個URL。 我想顯示當前正在使用的URL現在
這是我的XAML
<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" Background="AliceBlue" Icon="LGIcon.ico">
<Grid Height="341.077" Width="567.721" Background="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 Path=PrdFrstName, UpdateSourceTrigger=PropertyChanged}" Width="161" BorderThickness="2" BorderBrush="AliceBlue" Background="Red" Foreground="White" FontSize="13"></Label>
</StackPanel>
</Grid>
,這是我的窗口類。
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
End Sub
end class
沒有更新文本標籤整個功能運行良好。但我希望展示一些東西。我出錯的地方
我嘗試通過刪除少量零件到新創建的項目來進行數據綁定。它在那裏工作。所以在這段代碼中有一些錯誤? :`(
你的strComurl是如何設置的?或者如何調用subMainStrt函數? – Manish 2013-02-25 07:48:07
這個mainstrt函數在按鈕上點擊調用 – 2013-02-25 11:08:17