......
承接上一系列动画三。
在主界面后台代码设置嵌套第二个用户控件。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Data.SqlClient; using User.sqlHelper; using System.Data; using System.IO; using System.Drawing; namespace User { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public static string name = ""; public int usergrade = 1; private void Window_Loaded(object sender, RoutedEventArgs e) { myHelper.showWarnMessage += new myHelper.ShowWarnMessage(myHelper_showWarnMessage); } //传递登录界面的用户名 User_test _u = new User_test(); void myHelper_showWarnMessage(string _str) { //获取用户名 string _msg = _str; //传递名字到主页面 name = tb_name.Text = _msg; //根据用户名得到权限 usergrade = _u.getUserGrade(tb_name.Text); if (usergrade == 0) { } else if (usergrade == 1) { } else if (usergrade == 2) { } } //从这开始 public static bool isnew = false; //新建时嵌套另一个用户控件2在主页面上 private void btn_new_Click(object sender, RoutedEventArgs e) { isnew = true; //新建 uc_item _ucItem = new uc_item(); //设置号码初始化 //编号 _ucItem.tb_id.Text = "0"; //登录人 _ucItem.tb_uploader.Text = this.tb_name.Text; ////当前状态 //_ucItem.cb_type2.Text = _ucItem.cb_type.Text; //审批状态 _ucItem.loadCombobox(); //初始化信息添加到新建中 sp_1.Children.Add(_ucItem); Canvas.SetLeft(_ucItem, 0); sp_1.Height = Math.Max(sp_1.Children.Count * 50 ,930); } //从这结束 private void btn_nosolve_Click(object sender, RoutedEventArgs e) { } private void btn_solve_Click(object sender, RoutedEventArgs e) { } } }
结果: