Hello I have a ObservableCollection
that populates from a database.
Here is a print of the data being added to the collection:
7/15/2021 12:00:00 AM
Domestic
BENDING
BENDER11
testing
173-1
171-3 SILENCER
Waldo
1
[{"PartNum":"0.579x79.60x358.30HFS436L","PartDescription":"TYA A1 CHBR MTL","PartReason":"SPLIT COMP / MID LEFT","PartQty":1.0},{"PartNum":"18308-TJB-A021-Y1","PartDescription":"SILENCER, EXHAUST R","PartReason":"NG Cat Depth/ Misset","PartQty":3.0},{"PartNum":"18231-S10-0030","PartDescription":"BOLT COMP FLEX JOINT"
As you can see I store parts as JSON
I have the binding done for the SelectedItem
here
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock
Text="{Binding SelectedItem.ID, ElementName=listTickets, StringFormat='Ticket ID: {0}'}"
FontSize="20"/>
<TextBlock Text="{Binding SelectedItem.Date, ElementName=listTickets, StringFormat=MM-dd-yyyy}"
FontSize="15"
Margin="3,5,0,0"/>
</StackPanel>
<StackPanel Grid.Column="3" >
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding SelectedItem.Dept, ElementName=listTickets, StringFormat='Department: {0}'}"
FontSize="20"/>
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding SelectedItem.Createdby, ElementName=listTickets, StringFormat='Submitted by: {0}'}"
FontSize="15"/>
</StackPanel>
</Grid>
My question is how can I get Parts
from the SelectedItem
then Deserialize that and add it into the the DataGrid
with columns [PartNum, PartDescription, PartReason, PartQty]
I was trying some code behind stuff but couldn't really get it
Here is what I have tried which is just parsing the data from the selection from codebehind.
private void listTickets_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
JsonData partsJson = JsonSerializer.Deserialize<JsonData>(listTickets.SelectedValue.Parts);
}