public void AddTab(IPage page, string name = null, ImageSource image = null, string tag = null) { string txt = page.Title; ImageSource img = null; if (page.Image != null) { img = new BitmapImage(page.Image); } if (name != null) { txt = name; } if (image != null) { img = image; } TabHeader header = FindTab(page, txt, tag); if (header == null) { header = new TabHeader(); header.Text = txt; header.Image = img; header.Tag = tag; header.Page = new TabPage(page); header.Clicked += TabHeader_Clicked; header.CloseClicked += TabHeader_CloseClicked; header.Opened += TabHeader_Opened; header.Closed += TabHeader_Closed; page.SendData += SendEventData; // Send Current User Data SendCurrentUser(page); // Send Current Device List SendCurrentDevices(page); TabHeaders.Add(header); header.Open(TabHeaders.Count == 1); } SelectTab(header); }
public MainViewModel() { if (IsInDesignMode) { #region Tab页签 TabHeaders.Add(new HeaderInfo("概况(O)")); TabHeaders.Add(new HeaderInfo("发送(S)")); TabHeaders.Add(new HeaderInfo("接收(R)")); TabHeaders.Add(new HeaderInfo("交易记录(T)")); #endregion } else { Init(); } }
void Init() { if (AppSettingConfig.Default.AppConfig.MainWindowTabs != null) { AppSettingConfig.Default.AppConfig.MainWindowTabs.ForEach(x => TabHeaders.Add(x)); if (TabHeaders.Any(x => x.IsSelected)) { _selectedTabItem = TabHeaders.FirstOrDefault(x => x.IsSelected); } } TabItemCheckedCommand = new RelayCommand <HeaderInfo>(OnTabItemChecked); PageCommand = new RelayCommand <string>(OnPageCommand); ProgressCommand = new RelayCommand(OnProgressClick); NetWorkCommand = new RelayCommand <bool>(OnNetWorkClick); SetTaskInfos(); RegeistMessenger <string>(OnGetRequestTab); }