1

我试图在 WPF 中打开一个仅包含图像并作为加载窗口运行的窗口。

我以与所有功能相同的方式使用加载窗口。它在第一次使用时总是可以正常工作,但之后的每个窗口实例都有空白内容。即使我只是使用标签,它也会显示为空白。

我不明白为什么在第一个窗口之前的新窗口实例上会有一个块。这是我使用的代码:

        private void btnSaveNewProject_Click(object sender, RoutedEventArgs e)
    {
        Loading load = new Loading();

        load.Show();

        DataAccess da = new DataAccess();

        da.ExecuteActionQuery(
            "insert into tbl_Project(ClientID,Name,Description,Billable,FixedPrice,Status,BudgetCap,SalesOrder,ProjectSalesOrder,ProjectType)"
            + " values('"
            + Globals.GetClientId(pw.cbxClients.SelectedItem.ToString()) + "','"
            + pw.txtName.Text.ToString() + "','"
            + pw.txtDescription.Text.ToString() + "','"
            + pw.chxBillable.IsChecked.ToString() + "','"
            + pw.chxFixedPrice.IsChecked.ToString() + "','"
            + pw.cbxStatus.SelectedItem.ToString() + "','"
            + pw.numBudget.ContentText.ToString() + "','"
            + pw.numSalesOrder.ContentText.ToString() + "','"
            + pw.txtName.Text.ToString() + " - " + pw.numSalesOrder.ContentText.ToString() + "','"
            + pw.cbxProjectType.SelectedItem.ToString() + "')");

        load.Visibility = Visibility.Hidden;

        MessageBox.Show("New Project Created Successfully", "Create New Project");

        pw.Close();

        btnProject_Click(null, null);
    }

这是我的 xaml:

<Window x:Class="TT.Windows.Loading"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="" Height="100" Width="100" WindowStartupLocation="CenterScreen" WindowStyle="None">
<Grid>
    <Image Source="/TT;component/Resources/Sidebar-Search.ico" Height="75" Width="75" />
</Grid>

我所有需要进行数据库调用的点击事件都具有与此函数相同的结构:创建一个加载窗口,显示它,完成工作,然后关闭它。

我使用的图像设置为资源构建操作。

建议将不胜感激。

4

0 回答 0