Certainly! Below is an example of an AvaloniaUI XAML UserControl designed to display a typical EDI (Electronic Data Interchange) order in a human-friendly way. This control assumes you have a view model with properties for the order header, buyer/seller info, and a list of line items.
Assumptions for the ViewModel:
OrderNumber (string)
OrderDate (DateTime)
BuyerName (string)
BuyerAddress (string)
SellerName (string)
SellerAddress (string)
LineItems (ObservableCollection)
- Each
OrderLineItem has: ProductCode, Description, Quantity, UnitPrice, Total
EDIOrderView.xaml
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="YourNamespace.EDIOrderView">
<Border Padding="20" Background="#FFF" CornerRadius="8" BoxShadow="0 2 8 #888">
<StackPanel Spacing="16">
<!-- Order Header -->
<StackPanel Orientation="Horizontal" Spacing="40">
<StackPanel>
<TextBlock Text="Order Number:" FontWeight="Bold"/>
<TextBlock Text="{Binding OrderNumber}" />
</StackPanel>
<StackPanel>
<TextBlock Text="Order Date:" FontWeight="Bold"/>
<TextBlock Text="{Binding OrderDate, StringFormat='{}{0:yyyy-MM-dd}'}" />
</StackPanel>
</StackPanel>
<!-- Buyer/Seller Info -->
<StackPanel Orientation="Horizontal" Spacing="40">
<StackPanel>
<TextBlock Text="Buyer" FontWeight="Bold" FontSize="16"/>
<TextBlock Text="{Binding BuyerName}" />
<TextBlock Text="{Binding BuyerAddress}" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Seller" FontWeight="Bold" FontSize="16"/>
<TextBlock Text="{Binding SellerName}" />
<TextBlock Text="{Binding SellerAddress}" TextWrapping="Wrap"/>
</StackPanel>
</StackPanel>
<!-- Line Items Table -->
<DataGrid Items="{Binding LineItems}" AutoGenerateColumns="False" GridLinesVisibility="All" HeadersVisibility="All" CanUserResizeColumns="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Product Code" Binding="{Binding ProductCode}" Width="*"/>
<DataGridTextColumn Header="Description" Binding="{Binding Description}" Width="2*"/>
<DataGridTextColumn Header="Quantity" Binding="{Binding Quantity}" Width="*"/>
<DataGridTextColumn Header="Unit Price" Binding="{Binding UnitPrice, StringFormat='{}{0:C}'}" Width="*"/>
<DataGridTextColumn Header="Total" Binding="{Binding Total, StringFormat='{}{0:C}'}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
<!-- Order Total -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="Order Total: " FontWeight="Bold" FontSize="16"/>
<TextBlock Text="{Binding LineItems, Converter={StaticResource OrderTotalConverter}, StringFormat='{}{0:C}'}" FontSize="16"/>
</StackPanel>
</StackPanel>
</Border>
</UserControl>
Notes:
- OrderTotalConverter: You'd need to implement a value converter to sum the
Total of all line items.
- Styling: Adjust colors, spacing, and fonts as needed for your application.
- DataGrid: Avalonia's
DataGrid is used for line items for a tabular, readable display.
- ViewModel: Bind this control to a view model with the properties as described above.
If you need the C# ViewModel or the OrderTotalConverter, let me know!