mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
add data reading & selection table population
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:MercuryConverter.UI.Views"
|
||||
x:Class="MercuryConverter.UI.Views.Selection"
|
||||
|
||||
xmlns:data="clr-namespace:MercuryConverter.Data"
|
||||
>
|
||||
<DockPanel>
|
||||
<!-- Sidebar -->
|
||||
@@ -41,12 +43,12 @@
|
||||
<TextBox Watermark="Search for title, artist, designer..."/>
|
||||
</DockPanel>
|
||||
<UserControl Background="{DynamicResource DataGridContentBackground}">
|
||||
<DataGrid Name="ListingTable" IsReadOnly="True" SelectionMode="Extended" ItemsSource="{Binding SongCollection}">
|
||||
<DataGrid Name="ListingTable" IsReadOnly="True" SelectionMode="Extended" ItemsSource="{x:Static data:Database.Songs}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID" Width="90" Binding="{Binding Id}"/>
|
||||
<DataGridTextColumn Header="Title" Width="*" Binding="{Binding Name}"/>
|
||||
<DataGridTextColumn Header="Artist" Width="*" Binding="{Binding Artist}"/>
|
||||
<DataGridTextColumn Header="Source" Width="150" Binding="{Binding Source}"/>
|
||||
<DataGridTextColumn Header="Source" Width="150" Binding="{Binding SourceName}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</UserControl>
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace MercuryConverter.UI.Views;
|
||||
|
||||
public partial class Selection : Panel
|
||||
{
|
||||
public static ObservableCollection<Song> SongCollection { get; } = new();
|
||||
public Selection()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -41,40 +40,6 @@ public partial class Selection : Panel
|
||||
);
|
||||
}
|
||||
|
||||
SongCollection.CollectionChanged += OnSongsChg;
|
||||
DataContext = this;
|
||||
|
||||
// placeholder data
|
||||
if (SongCollection.Count == 0)
|
||||
{
|
||||
SongCollection.Add(
|
||||
new Song { Id = "S00-000", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[2] }
|
||||
);
|
||||
SongCollection.Add(
|
||||
new Song { Id = "S00-001", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[3] }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSongsChg(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
Console.WriteLine("Songs collection changed!");
|
||||
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
Console.WriteLine("Added...");
|
||||
foreach (Song added in e.NewItems)
|
||||
{
|
||||
Console.WriteLine($"[{added.Id}] {added.Artist} - {added.Name}");
|
||||
}
|
||||
}
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
Console.WriteLine("Removed...");
|
||||
foreach (Song rem in e.OldItems)
|
||||
{
|
||||
Console.WriteLine($"[{rem.Id}] {rem.Artist} - {rem.Name}");
|
||||
}
|
||||
}
|
||||
// DataContext = this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user