I'm trying to figure out what kind of control the favorites bar is in IE/Firefox, etc. Basically something that you can visually store bookmarks on, move around, delete easily.
I've tried doing something with a ToolBar, and while I can add buttons and make them work like I want, deleting and rearranging them is problematic. I also tried listviews, but getting them to display correctly is proving difficult. Maybe something like large icon view, without the icons.
I'm just looking for something where people can bookmark Navigation Pages to go back to one they were looking at before.
Edit:
I guess I don't really even care about the rearranging all that much. I'm just trying to figure out how to
I've tried this as a test:
<ListView Grid.Row="1" Name="ListView1">
<WrapPanel>
<WrapPanel.ContextMenu>
<ContextMenu>
<MenuItem Name="mnuDelete" Header="Delete" />
</ContextMenu>
</WrapPanel.ContextMenu>
<Button Name="AddSite">+</Button>
<ListViewItem Content="Test 1" />
<ListViewItem Content="Test 2" />
</WrapPanel>
</ListView>
But I can't even select either of the listviewitems, let alone click on them. If I right click on one, it doesn't tell me which one I've clicked on in the context menu event handler.
It's frustrating because in WinForms I would have had this done already. I can't wait until I've picked up enough so that WPF just starts clicking. I feel like I'm moving from VB6 to VB.Net all over again, but more so.
So I think I got it working the way I want, minus the reordering.
I can live with that for now.
XAML:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Tracks" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="26" />
<RowDefinition Height="265*" />
</Grid.RowDefinitions>
<Menu Name="Menu1" />
<Frame Grid.Row="2" Name="Frame1" Source="PageSearchResults.xaml" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<Button Name="AddSite">+</Button>
<ListView Name="ListView1" MouseDoubleClick="ListViewItem_MouseDoubleClick">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Name="mnuDelete" Header="Delete" />
</ContextMenu>
</ListView.ContextMenu>
</ListView>
</StackPanel>
</Grid>
</Window>
VB:
Class MainWindow
Dim bookmarks As New ArrayList
Private Sub mnuDelete_click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles mnuDelete.Click
If Not ListView1.SelectedValue Is Nothing Then
bookmarks.RemoveAt(ListView1.SelectedValue)
End If
ListView1.Items.RemoveAt(ListView1.SelectedIndex)
End Sub
Private Sub AddSite_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles AddSite.Click
Dim i As Integer = 0
Dim itmX As Integer
Dim itm As New ListViewItem
i = bookmarks.Add(Frame1.Content)
itmX = ListView1.Items.Add(New DictionaryEntry(i, Frame1.Content.title))
ListView1.DisplayMemberPath = "Value"
ListView1.SelectedValuePath = "Key"
End Sub
Private Sub ListViewItem_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If Not ListView1.SelectedValue Is Nothing Then
Frame1.Content = bookmarks(ListView1.SelectedValue)
End If
End Sub
End Class
And that gives adding and deleting bookmarks in WPF window with a frame and a listview as a bookmark bar. I'm open to suggestions to improve it or better ways to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With