L
Lloyd Sheen
I have the following XAML code in a usercontrol (this is just a list of
folders)
:
<ListView x:Name="CDList" DockPanel.Dock="Top"
Background="Transparent" SelectionMode="Single">
<ListView.ItemTemplate >
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<Button Name="CDButton" Click="CDButton_Click"
Tag="{Binding }" Background="Transparent"
..... (not relevant).
When I click the button on the page:
The code for the CDButton_Click is called just once which is expected.
The code in the event handler is :
Private Sub CDButton_Click(ByVal sender As System.Object, ByVal e As
System.Windows.RoutedEventArgs)
Dim rf As RFolder = CType(CType(sender, Button).Tag, RFolder)
RaiseEvent FolderSelected(Me, rf)
End Sub
The raiseevent is executed only once.
The code in the event handler is:
Private Sub CDList_FolderSelected(ByVal sender As Object, ByVal rf As
RFolder) Handles CDList.FolderSelected
RaiseEvent FolderSelected(Me, rf)
End Sub
If this looks wierd it is because there is a main page which hosts the
navigator controls which raise and event when clicked and then the navigator
control will pass the raised event on to the main page.
The mainwindow event handler code is (note it is executed for all the
different navigators):
Private Sub theFolderNavigator_FolderSelected(ByVal sender As Object, ByVal
rf As RFolder) Handles theFolderNavigator.FolderSelected,
ArtistNavPanel.FolderSelected, CDByDateNav.FolderSelected
Dim songs As List(Of RSongInfo)
songs = (From s In dc.RSongInfos Where s.FolderNumber = rf.FolderNumber
Select s Order By s.Album, s.TrackNumber Ascending).ToList
PopulateSongList(rf, songs)
End Sub
So the sequence of events is:
1. Click the button
2. Sub CDButton_Click is called
3. Sub CDList_FolderSelected is called (raiseevent)
4. Sub theFolderNavigator_FolderSelected is called (raiseevent) (sender
is FolderNavigator)
5. Sub theFolderNavigator_FolderSelected is called a second time (WTF?)
(sender is FolderNavigator)
This is like ASP when you can have the event happen twice if is auto fire
and you use the handles clause in VB.
It really seems to me that WPF is in the spot that ASP was with 1.0. There
are way to many things that go wrong and require workarounds.
Thanks
Lloyd Sheen
folders)
:
<ListView x:Name="CDList" DockPanel.Dock="Top"
Background="Transparent" SelectionMode="Single">
<ListView.ItemTemplate >
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<Button Name="CDButton" Click="CDButton_Click"
Tag="{Binding }" Background="Transparent"
..... (not relevant).
When I click the button on the page:
The code for the CDButton_Click is called just once which is expected.
The code in the event handler is :
Private Sub CDButton_Click(ByVal sender As System.Object, ByVal e As
System.Windows.RoutedEventArgs)
Dim rf As RFolder = CType(CType(sender, Button).Tag, RFolder)
RaiseEvent FolderSelected(Me, rf)
End Sub
The raiseevent is executed only once.
The code in the event handler is:
Private Sub CDList_FolderSelected(ByVal sender As Object, ByVal rf As
RFolder) Handles CDList.FolderSelected
RaiseEvent FolderSelected(Me, rf)
End Sub
If this looks wierd it is because there is a main page which hosts the
navigator controls which raise and event when clicked and then the navigator
control will pass the raised event on to the main page.
The mainwindow event handler code is (note it is executed for all the
different navigators):
Private Sub theFolderNavigator_FolderSelected(ByVal sender As Object, ByVal
rf As RFolder) Handles theFolderNavigator.FolderSelected,
ArtistNavPanel.FolderSelected, CDByDateNav.FolderSelected
Dim songs As List(Of RSongInfo)
songs = (From s In dc.RSongInfos Where s.FolderNumber = rf.FolderNumber
Select s Order By s.Album, s.TrackNumber Ascending).ToList
PopulateSongList(rf, songs)
End Sub
So the sequence of events is:
1. Click the button
2. Sub CDButton_Click is called
3. Sub CDList_FolderSelected is called (raiseevent)
4. Sub theFolderNavigator_FolderSelected is called (raiseevent) (sender
is FolderNavigator)
5. Sub theFolderNavigator_FolderSelected is called a second time (WTF?)
(sender is FolderNavigator)
This is like ASP when you can have the event happen twice if is auto fire
and you use the handles clause in VB.
It really seems to me that WPF is in the spot that ASP was with 1.0. There
are way to many things that go wrong and require workarounds.
Thanks
Lloyd Sheen