我有一個Silverlight數據網格,允許用戶輸入您計劃訂購的產品數量。已經填充的是他的物品成本。現在我有一個事件,一旦完成編輯後,單元格會檢查該標題,但是如何將這兩個單元格相乘並將該值放入成本列中的某個單元格中。我知道我真的會改變綁定到我的數據網格的對象列表,但我不知道如何做到這一點。乘法Silverlight Datagrid
client.GetOrderCompleted += (s, ea) =>
{
dgOrder.AutoGenerateColumns = false;
//dgOrder.ColumnWidth.Value = 100;
dgOrder.Columns.Add(CreateTextColumn("SKU", "SKU"));
dgOrder.Columns.Add(CreateTextColumn("productname", "Product Name"));
dgOrder.Columns.Add(CreateTextColumn("itemnumber", "Item Number"));
dgOrder.Columns.Add(CreateTextColumn("cost", "Cost"));
dgOrder.Columns.Add(CreateTextColumn("asin", "ASIN"));
dgOrder.Columns.Add(CreateTextColumn("pendingorder", "Rank"));
dgOrder.Columns.Add(CreateTextColumn("rank", "Node"));
//dgOrder.Columns.Add(CreateTextColumn("w4", "AMZN"));
dgOrder.Columns.Add(CreateTextColumn("amazon", "AMZN"));
dgOrder.Columns.Add(CreateTextColumn("ourprice", "OurPrice"));
dgOrder.Columns.Add(CreateTextColumn("bbprice", "BuyBox"));
dgOrder.Columns.Add(CreateTextColumn("afner", "AFN"));
dgOrder.Columns.Add(CreateTextColumn("quantity", "INV"));
dgOrder.Columns.Add(CreateTextColumn("w4", "W4"));
dgOrder.Columns.Add(CreateTextColumn("w3", "W3"));
dgOrder.Columns.Add(CreateTextColumn("w2", "W2"));
dgOrder.Columns.Add(CreateTextColumn("w1", "W1"));
dgOrder.Columns.Add(CreateTextColumn("order", "Order"));
dgOrder.Columns.Add(CreateTextColumn("total", "Total"));
dgOrder.Columns.Add(CreateTextColumn("profit", "Profit"));
dgOrder.Columns.Add(CreateTextColumn("percent", "Percent"));
dgOrder.Columns.Add(CreateHyperlink("asin"));
dgOrder.ItemsSource = ea.Result;
Original = ea.Result;
};
client.GetOrderAsync(txtBox.Text);
XAML:
<sdk:DataGrid AutoGenerateColumns="True"
Height="469"
HorizontalAlignment="Left"
Margin="12,41,0,0"
Name="dgOrder"
VerticalAlignment="Top"
Width="1316"
HeadersVisibility="All"
CellEditEnded="dgOrder_CellEditEnded"
RowBackground="DodgerBlue"
AlternatingRowBackground="LightBlue"
LostFocus="TextBox_LostFocus"
BeginningEdit="dgOrder_BeginningEdit"
SelectionChanged="dgOrder_SelectionChanged"
LoadingRow="dgOrder_LoadingRow" />
您可以更改綁定到您的數據網格的對象,以便所需的屬性自動計算爲成本*金額,然後它應該自動更新。 – Tsabo