private void btnNew_Click(object sender, RoutedEventArgs e)
 {
     var ud = new UserDetail();
     ud.DataContext = new User();
     ud.ControlMode = ControlMode.New;
     if (ZeroMessageBox.Show(ud, ZeroConfiguration.Properties.Resources.NewUser, SizeToContent.WidthAndHeight).GetValueOrDefault())
     {
         string message;
         if(User.TryCreateUser((User)ud.DataContext,out message))
             LoadUsers();
         else
         {
             ZeroMessageBox.Show(message, "Error");
         }
     }
 }
 private void btnEditUser_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var ud = new UserDetail();
         ud.DataContext = _userCol.FirstOrDefault(user => user.Code.Equals(((Button) sender).DataContext));
         ud.ControlMode = ControlMode.Update;
         if (ZeroMessageBox.Show(ud, ZeroConfiguration.Properties.Resources.EditUser, SizeToContent.WidthAndHeight).GetValueOrDefault())
         {
             User.UpdateUser((User) ud.DataContext);
             users.UpdateLayout();
         }
     }
     catch (Exception ex)
     {
         ZeroMessageBox.Show(ex, "Error", ResizeMode.NoResize, MessageBoxButton.OK);
     }
 }