General newbie to WPF, so bear with me.
I built the proof of the conceptual application before continuing with it. I decided to give it go WPF.
This is the scenario:
I have:
- a View = CustomerView (userControl with Buy item button)
- txtbox (add all actions that occur)
- ViewModel = CustomerViewModel (negotiates with the service, etc. and gets the results
- Model = Customer (simple class with properties with InotifyPropertyChanged embedded
Given that I have a set of products, and for each product I buy, I need to APPLY TEXT. In txtBox in userControl output all the actions that occur, the text field should look like
Start buying .....
Product 1 Sold
Product 2 Sold
Fineshed....
, , , , , " 1 , 2 .
Windows userControl ProductStatus, , , .
" beginInvoke, threadCross" . ,
private ProductStatus _productStatus;
public ProductStatus Status
{
get { return _productStatus; }
set
{
_printStatus = value;
BeginInvoke((MethodInvoker)(() => txtProductResult.AppendText(string.Format("Product Sold {0}", Environment.NewLine))));
}
}
myTextBox ?
================= =========================== ====
void LogChanged(object sender, NotifyCollectionChangedEventArgs e)
{
foreach(object item in e.NewItems)
{
txtProduct.AppendText(item.ToString());
}
}
<TextBox Margin="12,41,12,59" Name="txtPrintResult" />
<TextBox Text="{Binding TicketPrintLog, Mode=OneWay}" Margin="12,41,12,12" />
ProductModel
=============
public string ProductLog{ get; set; }
ProductViewModel
==================
public string ProductLog
{
get { return _ProductModel.ProductLog; }
}
internal void AppendToProductLogText(string text)
{
_ProductModel.ProductLog += text + Environment.NewLine;
OnPropertyChanged("ProductLog");
}
void ProductSoldNotificationReceived(object sender, notificationEventArgs e)
{
AppendToProductLogText(e.Message);
}
ProductView (userControl) XAML
================================
<TextBox Margin="12,41,12,59" Name="txtResult" Text="{Binding ProductLog, Mode=OneWay}" />
IN CODE BEHIND I DO
public void Action1()
{
txtResult.AppendText(_productViewModel.ProductLog);
}
public void SellProductAction()
{
txtResult.AppendText(_productViewModel.ProductLog);
}
,
txtResult.AppendText(_productViewModel.ProductLog);
SellproductAction, , Product1, 2 ..