I have 2 XAML pages :
a) PagePrinting.xaml
b) FormattedPage.xaml
--1--- in FormattedPage.xaml , I have a RichtextBlock :
<RichTextBlock>
<Paragraph>
<InlineUIContainer>
<ItemsControl ItemsSource="{Binding YourItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<!-- Data Template -->
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</InlineUIContainer>
</Paragraph>
</RichTextBlock>
------2-- In PagePrinting.xaml :
I have the data from SQLite Db for FormattedPage.XAML for above (1)
ObservableCollection <Transaction> TransCollection = new ObservableCollection <Transaction>();
OnPageLoad :
TransCollection.Clear();
var db = new SQLiteAsyncConnection(dbPath);
var Trans = await db.QueryAsync <BizTransaction>("Select * From BizTransaction Where SalesId = '" + Id + "'");
int intRecord = Trans.Count();
if (intRecord != 0)
{
foreach (var _trans in Trans)
{
int Id = _trans.Id;
string Name = _trans.Description;
string ItemNo = _trans.No;
int Qty = (int)_trans.Quantity;
decimal Price = _trans.UnitPrice;
decimal LineAmt = _trans.LineAmount;
//-- create a collection
AddToList(Id, Name, ItemNo, Qty, Price, LineAmt);
}
this.DataContext = TransCollection;
FrameworkElement page1;
page1 = new FormattedPage();
page1.DataContext = this.DataContext;
CanvasPrintContainer.Children.Add(page1);
The problems:
1) is this correct ?
this.DataContext = TransCollection;
page1.DataContext = this.DataContext;
2) How to do Binding in FormattedPage.xaml using this DataContext?
3) What need to be done in xaml section for PagePrinting for DataBinding ?
Thanks