本文整理汇总了C#中System.Windows.Controls.TabItem.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# TabItem.SetBinding方法的具体用法?C# TabItem.SetBinding怎么用?C# TabItem.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TabItem
的用法示例。
在下文中一共展示了TabItem.SetBinding方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
var source = (IEnumerable)value;
if (source != null)
{
var tabItems = new List<TabItem>();
foreach (object item in source)
{
var tabItem = new TabItem
{
DataContext = item,
Content = new ContentControl { Template = (ControlTemplate)parameter }
};
var binding = new Binding("DisplayName");
tabItem.SetBinding(TabItem.HeaderProperty, binding);
tabItems.Add(tabItem);
}
return tabItems;
}
return null;
}
catch (Exception)
{
return null;
}
}
示例2: MakeNewTab
private TabItem MakeNewTab(FileLoader currentLoader)
{
var newTab = new TabItem {DataContext = new FileData(currentLoader)};
var headerBinding = new Binding("Name");
headerBinding.Mode = BindingMode.OneTime;
newTab.SetBinding(HeaderedContentControl.HeaderProperty, headerBinding);
newTab.Content = new FileView();
return newTab;
}
示例3: AddTab
private void AddTab(UIElement content, string header)
{
var tabItem = new TabItem {
Content = content,
Header = header,
};
tabItem.SetBinding(VisibilityProperty, new Binding {
Path = new PropertyPath(VisibilityProperty),
Source = content
});
this.tabControl.Items.Add(tabItem);
}
示例4: CreateTabItem
private static TabItem CreateTabItem()
{
var tabItem = new TabItem
{
Width = 150,
Height = 20,
IsSelected = true,
Content = CreateNewTab()
};
tabItem.SetBinding(HeaderedContentControl.HeaderProperty, new Binding("Content.DataContext.Title")
{
RelativeSource = RelativeSource.Self
});
return tabItem;
}
示例5: AddTabItem
private void AddTabItem(object vm)
{
var view = new ProviderView();
var tab = new TabItem
{
DataContext = vm,
Content = new ModernWPF.Controls.ModernContentControl { Content = view }
};
tab.SetBinding(TabItem.HeaderProperty, new Binding("Name"));
theTabs.Items.Add(tab);
// When there is only 1 Item, the tab can't be rendered without have it selected
// Don't do Refresh(). This may clear
// the Selected item, causing issue in the ViewModel
if (theTabs.SelectedItem == null)
tab.IsSelected = true;
}
示例6: CreatePages
private void CreatePages()
{
var layers = new TabItem()
{
Header = "Слои",
Content = ElementsViewModel
};
Binding visibilityBinding = new Binding("SelectedPlan");
visibilityBinding.Source = this;
visibilityBinding.Converter = new NullToVisibilityConverter();
layers.SetBinding(TabItem.VisibilityProperty, visibilityBinding);
TabPages = new List<TabItem>()
{
layers
};
SelectedTabIndex = -1;
}
示例7: AssociationsView_Loaded
void AssociationsView_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (AssociationTabs.Items.Count == 0)
{
//Managed Profiles Tab
TabItem profilesTab = new TabItem();
profilesTab.Header = "Managed Profiles";
ProfilesView profilesView = new ProfilesView();
ProfilesViewModel profilesViewModel = KernelContainer.Kernel.Get<ProfilesViewModel>();
profilesViewModel.AssociationManagerId = ViewModel.AssociationManagerId;
profilesViewModel.BookingEnginePanel = BookingEnginePanel;
profilesView.DataContext = profilesViewModel;
profilesTab.Content = profilesView;
//Saved Address Tab
TabItem savedAddressTab = new TabItem();
savedAddressTab.Header = "Saved Address";
SavedAddressListView savedAddressListView = new SavedAddressListView();
//SavedAddressListViewModel savedAddressListViewModel = KernelContainer.Kernel.Get<SavedAddressListViewModel>();
//savedAddressListView.DataContext = savedAddressListViewModel;
savedAddressTab.Content = savedAddressListView;
TabItem savedBillingTab = new TabItem();
savedBillingTab.Header = "Saved Billing";
Segator.Loms.Modules.Associations.Silverlight.SavedBilling.BillingView savedBillingView = new Segator.Loms.Modules.Associations.Silverlight.SavedBilling.BillingView();
//BillingViewModel savedBillingViewModel = KernelContainer.Kernel.Get<BillingViewModel>();
//savedBillingView.DataContext = savedBillingViewModel;
savedBillingTab.Content = savedBillingView;
TabItem historyTab = new TabItem();
historyTab.Header = "History";
HistoryView historyView = new HistoryView();
HistoryViewModel historyViewModel = KernelContainer.Kernel.Get<HistoryViewModel>();
historyViewModel.BookingEnginePanel = BookingEnginePanel;
historyView.DataContext = historyViewModel;
historyTab.Content = historyView;
TabItem myAwardsTab = new TabItem();
myAwardsTab.Header = " Limo Points";
MyAwardsView myAwardsView = new MyAwardsView();
myAwardsTab.Content = myAwardsView;
//My Admin Tab
TabItem myAdminTab = new TabItem();
myAdminTab.Header = "My Admin";
MyAdminView myAdminView = new MyAdminView();
MyAdminViewModel myAdminViewModel = KernelContainer.Kernel.Get<MyAdminViewModel>();
myAdminViewModel.AssociationManagerId = ViewModel.AssociationManagerId;
myAdminView.DataContext = myAdminViewModel;
myAdminTab.Content = myAdminView;
AssociationTabs.Items.Add(profilesTab);
AssociationTabs.Items.Add(savedAddressTab);
AssociationTabs.Items.Add(savedBillingTab);
AssociationTabs.Items.Add(historyTab);
AssociationTabs.Items.Add(myAwardsTab);
AssociationTabs.Items.Add(myAdminTab);
Binding b = new Binding("MyAdminTabVisibility");
b.Source = DataContext;
myAdminTab.SetBinding(TabItem.VisibilityProperty, b);
}
}
示例8: OpenGraphInNewTab
/// <summary>
///
/// </summary>
/// <param name="seq_"></param>
public void OpenGraphInNewTab(SequenceBase seq_)
{
foreach (TabItem item in tabControl.Items)
{
if ((item.DataContext as FlowGraphControlViewModel).ID == seq_.Id)
{
tabControl.SelectedItem = item;
return;
}
}
TabItem tab = new TabItem();
FlowGraphControlViewModel fgvm = FlowGraphManager.Instance.GetViewModelByID(seq_.Id);
tab.DataContext = fgvm;
FlowGraphControl fgc = new FlowGraphControl();
fgc.DataContext = fgvm;
tab.Content = fgc;
Binding bind = new Binding("Name");
bind.Source = fgvm;
tab.SetBinding(TabItem.HeaderProperty, bind);
tabControl.SelectedIndex = tabControl.Items.Add(tab);
}
示例9: AddNewTab
private void AddNewTab(IDirectoryView view, FileSystemBase fileSystem)
{
//create new TabItem & apply style
TabItem ti = new TabItem();
ti.Style = (Style)Resources["CloseableTabItem"];
UserControl viewCtrl = (UserControl)view;
viewCtrl.Height = double.NaN;//same as Auto in XAML
viewCtrl.VerticalAlignment = VerticalAlignment.Stretch;
viewCtrl.Width = double.NaN;
viewCtrl.HorizontalAlignment = HorizontalAlignment.Stretch;
//events
view.ItemExecuted += ActiveView_ItemExecuted;
//set file system
if (fileSystem != null)
view.ChangeFileSystem(fileSystem);
//set content listview as content of tabitem
ti.Content = view;
//add tabitem to tabcontrol
tcViews.Items.Insert(tcViews.Items.Count - 1, ti);
tcViews.SelectedIndex = tcViews.Items.Count - 2;//QSTN: Why new tab must be selected, to gain header?
//bind header
Binding bind = new Binding("FileSystem.DirectoryName");
bind.Source = view;
ti.SetBinding(TabItem.HeaderProperty, bind);
}
示例10: CreateWorkerTabItem
/// <summary>
/// Creates the user interface elements for a Worker
/// </summary>
private void CreateWorkerTabItem( Worker worker )
{
// Create UI objects for this worker
WorkerView view = new WorkerView();
WorkerViewModel viewModel = new WorkerViewModel();
TabItem tabItem = new TabItem();
// Connect events, bindings and UI elements
viewModel.InitializeBindings( worker ); ;
view.DataContext = viewModel;
tabItem.Header = viewModel.WorkerName;
tabItem.Content = view;
tabItem.DataContext = viewModel;
tabItem.SetBinding( TabItem.HeaderProperty, "WorkerName" );
// Add the Tab to the UI
m_TabItemsDictionary[ worker ] = tabItem;
TabItems.Add( tabItem );
}
示例11: CreatePages
private void CreatePages()
{
var layers = new TabItem()
{
Header = "Слои",
Content = ElementsViewModel
};
Binding visibilityBinding = new Binding("SelectedPlan");
visibilityBinding.Source = this;
visibilityBinding.Converter = (IValueConverter)Application.Current.FindResource("NullToVisibilityConverter");
layers.SetBinding(TabItem.VisibilityProperty, visibilityBinding);
TabPages = new List<TabItem>()
{
new TabItem()
{
Header = "Планы",
Content = PlansTreeViewModel
},
layers
};
}
示例12: AddTabItem
/// <summary>
/// Adds <see cref="TabItem"/> for the content object
/// </summary>
/// <param name="item">Content of the <see cref="TabItems"/></param>
private void AddTabItem(object item)
{
ContentControl contentControl = new ContentControl();
TabItem tab = new TabItem
{
DataContext = item,
Content = contentControl,
HeaderTemplate = _tabControl.ItemTemplate
};
contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
tab.SetBinding(TabItem.HeaderProperty, new Binding());
_tabControl.Items.Add(tab);
}