我创建了一个应用程序,其中有标签。单击按钮时,我需要更新 label.content。
XAML
<Label x:Name="lblTaxExcise" Content="Excise" HorizontalAlignment="Left" Margin="10,0,0,112" Grid.Row="2" Width="47" Height="29" VerticalAlignment="Bottom"/>
<Label x:Name="lblTaxEdu" Content="Edu. Cess" HorizontalAlignment="Left" Margin="10,0,0,78" Grid.Row="2" Width="68" Height="29" VerticalAlignment="Bottom"/>
<Label x:Name="lblTaxVat" Content="VAT" HorizontalAlignment="Left" Margin="10,0,0,44" Grid.Row="2" Width="35" Height="29" VerticalAlignment="Bottom"/>
C#
SqlCeCommand com1 = new SqlCeCommand("SELECT ExciseTax, EduCessTax, VatTax FROM Tax_Master", con);
SqlCeDataReader dr1 = com1.ExecuteReader();
while (dr1.Read())
{
Excise = Convert.ToInt32(dr1[0]);
EduCess = Convert.ToInt32(dr1[1]);
Vat = Convert.ToInt32(dr1[2]);
}
lblTaxExcise.Content = "Excise @ " + Excise;
lblTaxEdu.Content = "Edu. Cess @ " + EduCess;
lblTaxVat.Content = "VAT @ " + Vat;
部分值是从数据库中获取的。