tabitem

WPF - TabItem Background color changes when tabitem selected or hover over

早过忘川 提交于 2019-11-27 22:54:18
I set the Background color of the tabitem in the xaml to RED, but when i run it and hover over it or select it it changes back the the default greyish looking. It only shows correctly when the other tabitem is selected. How do i keep it RED all the time. Thanks! Eugene Cheverda Here is example of TabItem ControlTemplate Copy it to your resources and set wherever you need Red color as Background. SAMPLE <Window x:Class="TestCustomTab.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300"

How to programmatically select a TabItem in WPF TabControl

左心房为你撑大大i 提交于 2019-11-27 21:02:31
I would like to know how to select a specific TabItem in a WPF TabControl. I tried these bellow but nothing work! MyTabControl.SelectedIndex = x MyTabControl.SelectedItem = MyTabItem MyTabControl.SelectedValue = MyTabItem MyTabItem.IsSelected = True As @Chris says, any of the first three things should work and as @Phyxx says, it doesn't always really work. The problem is some subtle thing about the order of property changes. To work around it you need to let the WPF invoke your tab-selection code in its own time: Dispatcher.BeginInvoke((Action)(() => MyTabControl.SelectedIndex = x)); This does

TabItem in a separate XAML

你离开我真会死。 提交于 2019-11-27 18:51:05
Is it possible to put a TabItem into a separate XAML and reference something like this: <TabControl> <local:MyTabItem/> </TabControl> In Separate XAML: <UserControl x:Class="MyProject.MyTabItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <TabItem Header="MyTab"> </TabItem> </UserControl> Of course it doesn't work, but I am wondering how can I do this? If what you want to do is simply make the code more manageable then I would recommend defining each tab's data in a user control, but still have the TabItem in the

In C# WPF, why is my TabControl's SelectionChanged event firing too often?

牧云@^-^@ 提交于 2019-11-27 03:47:36
I have a tabbed GUI with each tab containing a Frame. In one of these Frames there is a DataGrid. When the user selects this tab, I need my datagrid sorted, so I'm using the TabControl SelectionChanged event to trigger the sort. However, this event triggers every time an item is selected from the DataGrid, even though the tabs themselves remain untouched. I've tried number of different events: GotFocus for a TabItem RequestBringIntoView for a TabItem but they all seem to suffer from this problem. What is causing this? The TabControl.SelectionChanged is the same event as a ComboBox

WPF - TabItem Background color changes when tabitem selected or hover over

…衆ロ難τιáo~ 提交于 2019-11-26 21:14:02
问题 I set the Background color of the tabitem in the xaml to RED, but when i run it and hover over it or select it it changes back the the default greyish looking. It only shows correctly when the other tabitem is selected. How do i keep it RED all the time. Thanks! 回答1: Here is example of TabItem ControlTemplate Copy it to your resources and set wherever you need Red color as Background. SAMPLE <Window x:Class="TestCustomTab.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

How to programmatically select a TabItem in WPF TabControl

给你一囗甜甜゛ 提交于 2019-11-26 20:32:03
问题 I would like to know how to select a specific TabItem in a WPF TabControl. I tried these bellow but nothing work! MyTabControl.SelectedIndex = x MyTabControl.SelectedItem = MyTabItem MyTabControl.SelectedValue = MyTabItem MyTabItem.IsSelected = True 回答1: As @Chris says, any of the first three things should work and as @Phyxx says, it doesn't always really work. The problem is some subtle thing about the order of property changes. To work around it you need to let the WPF invoke your tab

TabItem in a separate XAML

空扰寡人 提交于 2019-11-26 19:37:36
问题 Is it possible to put a TabItem into a separate XAML and reference something like this: <TabControl> <local:MyTabItem/> </TabControl> In Separate XAML: <UserControl x:Class="MyProject.MyTabItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <TabItem Header="MyTab"> </TabItem> </UserControl> Of course it doesn't work, but I am wondering how can I do this? 回答1: If what you want to do is simply make the code more

In C# WPF, why is my TabControl&#39;s SelectionChanged event firing too often?

北城余情 提交于 2019-11-26 10:56:57
问题 I have a tabbed GUI with each tab containing a Frame. In one of these Frames there is a DataGrid. When the user selects this tab, I need my datagrid sorted, so I\'m using the TabControl SelectionChanged event to trigger the sort. However, this event triggers every time an item is selected from the DataGrid, even though the tabs themselves remain untouched. I\'ve tried number of different events: GotFocus for a TabItem RequestBringIntoView for a TabItem but they all seem to suffer from this

How do I bind a TabControl to a collection of ViewModels?

↘锁芯ラ 提交于 2019-11-26 00:47:43
问题 Basically I have in my MainViewModel.cs: ObservableCollection<TabItem> MyTabs { get; private set; } However, I need to somehow be able to not only create the tabs, but have the tabs content be loaded and linked to their appropriate viewmodels while maintaining MVVM. Basically, how can I get a usercontrol to be loaded as the content of a tabitem AND have that usercontrol wired up to an appropriate viewmodel. The part that makes this difficult is the ViewModel is not supposed to construct the