Показаны сообщения с ярлыком TabControl. Показать все сообщения
Показаны сообщения с ярлыком TabControl. Показать все сообщения

вторник, 2 июня 2020 г.

Wpf TabControl, TabItem used space Background Color

https://stackoverflow.com/questions/19864054/wpf-changing-background-behind-tabs-for-tabcontrol-when-tabitems-are-centered

<TabControl>
    <TabControl.Resources>
        <Style TargetType="{x:Type Grid}">
            <Setter Property="Background" Value="Red"/>
        </Style>
        <Style TargetType="{x:Type TabPanel}">
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style>
    </TabControl.Resources>
    <TabItem Header="Test 1"/>
    <TabItem Header="Test 2"/>
    <TabItem Header="Test 3"/>
    <TabItem Header="Test 4"/>
</TabControl>

понедельник, 1 июня 2020 г.

Wpf TabItem Events

https://stackoverflow.com/questions/8172077/tabchanged-event-of-tabcontrol-in-wpf/39017978

https://stackoverflow.com/questions/8172077/tabchanged-event-of-tabcontrol-in-wpf

https://stackoverflow.com/questions/43351422/event-before-user-changes-tabitem


https://stackoverflow.com/questions/8172077/tabchanged-event-of-tabcontrol-in-wpf/39017978

https://stackoverflow.com/questions/3659858/in-c-sharp-wpf-why-is-my-tabcontrols-selectionchanged-event-firing-too-often

     private void tabControlName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.Source is TabControl) //if this event fired from TabControl then enter
            {
                if (tabItemName.IsSelected)
                {
                    //Do your job here
                }
            }
        }
private void Window_Loaded(object sender, RoutedEventArgs e)
{
  ItemCollection view = tabControl.Items;
  view.CurrentChanged += new EventHandler(view_CurrentChanged);
}

void view_CurrentChanged(object sender, EventArgs e)
{
  throw new NotImplementedException();
}
3.
<TabControl SelectionChanged="OnTabItemChanged">
    <TabItem Name="MainTap" Header="Dashboard"></TabItem
</TabControl>
private async void OnTabItemChanged(object sender, SelectionChangedEventArgs e)
{

    TabControl tabControl = sender as TabControl; // e.Source could have been used instead of sender as well
    TabItem item = tabControl.SelectedValue as TabItem;
    if (item.Name == "MainTap")
    {
        Debug.WriteLine(item.Name);
    }
}

In the OnSelectedChanged handler,

if (Equals(sender, e.OriginalSource)) 

{ /* do the work */ } 

then all child events will not enter the conditional block