0

我创建了一个应用程序,其中有标签。单击按钮时,我需要更新 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;

部分值是从数据库中获取的。

4

2 回答 2

1

将标签宽度属性更改为自动。

于 2013-10-30T04:52:22.353 回答
1

只需删除标签的宽度即可。它应该可以工作

   <Label x:Name="lblTaxExcise" Content="Excise" HorizontalAlignment="Left" Margin="10,0,0,112" Grid.Row="2" Height="29" VerticalAlignment="Bottom"/>
   <Label x:Name="lblTaxEdu" Content="Edu. Cess" HorizontalAlignment="Left" Margin="10,0,0,78" Grid.Row="2" Height="29" VerticalAlignment="Bottom"/>
   <Label x:Name="lblTaxVat" Content="VAT" HorizontalAlignment="Left" Margin="10,0,0,44" Grid.Row="2" Height="29" VerticalAlignment="Bottom"/>
于 2013-10-30T04:54:40.033 回答