sskodje / wpfchrometabs-mvvm Goto Github PK
View Code? Open in Web Editor NEWA tab control based on WPF chrome tabs, modified to work with the MVVM pattern
License: MIT License
A tab control based on WPF chrome tabs, modified to work with the MVVM pattern
License: MIT License
I need some improvements for working with many tabs and have following ideas:
i found if remove the code in "Generic.xaml" file it can run,
<Style TargetType="{x:Type local:ChromeTabControl}"> .... .... </Style>but i can't remove it.Hope somebody help me,please~
Is there any way to add text (caption) to the AddButton (Add tab button)?
I want to place a "+โ symbol on the AddButton. So that the user knows they can open a new tab by clicking on that button.
Thank you.
The first window does not load the usercontrol at start, but after you switch between tabs it loads correctly.
A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
The program '[5796] Demo.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
This exception is thrown when there are two tabs open and you drag the other one to new window and then close the remaining tab and drag the window back to the TabControl (to grab it as a tab again).
if you don't set the Background, the AddTabButton didn't work. He is there but not clickable.
I want to Add Command: CloseAllExcludingPinnedTabsCommand
if tabitem is pinned, execute CloseAllTabCommand ,don't close the pinned tabitems
I use the MVVM Light tool box create project (WPF451)
and download with NuGet
but click the top add button can't work .
.NET Framework 4.5.1 + MVVM Light 5.2.0
So i try to change demo code , .NET Framework 4 -> .NET Framework 4.5.1
MVVM Light 5.2.0
i got the same problem.
Sometime a ArgumentOutOfRange exception in ChromeTabPanel.ProcessMouseMove(Point p) is thrown.
Problem is an access to a double array with an invalid index.
I suppose this could be the problem:
int localSlideIndex = this.slideIndex; if (margin.Left < this.slideIntervals[localSlideIndex - 1]) { SwapSlideInterval(localSlideIndex - 1); localSlideIndex -= 1; changed = 1; } else if (margin.Left > this.slideIntervals[localSlideIndex + 1]) { SwapSlideInterval(localSlideIndex + 1); localSlideIndex += 1; changed = -1; }
There is no check if localSlideIndex-1 is >= 0 and if it's < Count.
Please check all other source positions too.
If you select a tab and in so doing the tabs move up or down so the mouse is not longer over said tab - then when you move the mouse back over the tab it still moves around until you press and release the mouse button.
Is it possible to close a tab by pressing the middle mouse button like in Chrome?
My application is not receiving the close command when I press the middle button.
Title says it all. When setting MinWidth
, the ActualWidth
always stays at 0(Because it is readonly).
click or move mouse ,it crash
.net 5
vs2019
Hello,
I use ChromeTabs from NuGet in my application. Because my application is signed I get the error while ChromeTabs dll loading:
Could not load file or assembly 'ChromeTabs, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Could you sign the assembly in NuGet package? Thank you.
Currently it is possible to custom style the add tab button, but the size is hardcoded to new Size(20, 12)
. Line 111 in ChromeTabPanel.cs
.
I added properties AddButtonWidth
and AddButtonHeight
to ChromeTabControl.cs
, but my skills are kinda lacking to get this to work inside the ChromeTabPanel.cs
.
You have some pointers how to update the _addButtonSize
property inside ChromeTabPanel.cs
when the width or height is set from xaml?
Hi,
i am using chromeTabs and i really like it.
The only thing i am missing is the TabStripPlacement Property.
https://msdn.microsoft.com/en-us/library/system.windows.controls.tabcontrol.tabstripplacement(v=vs.110).aspx
I want to place the TabPanel on the left side of my control.
Is there any way to do this?
Sometime the chrome tab throws an out of bounds exception when clicking on a tab:
" at System.Windows.Controls.ItemCollection.GetItemAt(Int32 index)\r\n at ChromeTabs.ChromeTabControl.MoveTab(Int32 fromIndex, Int32 toIndex)\r\n at ChromeTabs.ChromeTabPanel.<>c__DisplayClass57_0.g__completed|0()\r\n at System.Windows.Media.Animation.Clock.FireEvent(EventPrivateKey key)\r\n at System.Windows.Media.Animation.Clock.RaiseAccumulatedEvents()\r\n at System.Windows.Media.Animation.TimeManager.RaiseEnqueuedEvents()\r\n at System.Windows.Media.Animation.TimeManager.Tick()\r\n at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)\r\n at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)\r\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)"
I'm not sure but maybe it can be fixed by doing more checks in MoveTab.
Current code:
if (Items.Count == 0 || fromIndex == toIndex || fromIndex >= Items.Count)
{
return;
}
object fromTab = Items[fromIndex]; //fromIndex could be < 0
object toTab = Items[toIndex]; //toIndex could be < 0 and outside of array!
Better:
if (fromIndex == toIndex || fromIndex >= Items.Count || toIndex >= Items.Count || toIndex < 0 || fromIndex < 0)
{
return;
}
But I'm not sure if it fixes the bug. The question is why is a invalid index passed to the function and why is MoveTab called if I click on a tab page and release the mouse button. This should not trigger a MoveTab operation.
Similar to WPF TabControl, is it possible to change the trabstrip placement to Bottom from the standard top location?
If you have only one Tab, you can move the whole Window with that tab, but if you add a new Tab after the dragging, you drag that new Tab directly after adding. It's reproduceable in the Demo.
Change TabControl style to the latest Google Chrome design.
N/a
N/a
I managed to recreate shape for the close button:
<Style TargetType="{x:Type Button}"
x:Key="CloseButtonStyle">
<Style.Resources>
<sys:Double x:Key="CloseButtonWidth">7</sys:Double>
<sys:Double x:Key="CloseCircleWidth">16</sys:Double>
<sys:Double x:Key="CloseButtonOffset">4.5</sys:Double>
</Style.Resources>
<Setter Property="Height"
Value="{StaticResource CloseCircleWidth}" />
<Setter Property="Width"
Value="{StaticResource CloseCircleWidth}" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Foreground"
Value="#45494C" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Canvas Background="Transparent"
x:Name="CloseButton"
Width="{StaticResource CloseCircleWidth}"
Height="{StaticResource CloseCircleWidth}">
<Ellipse Width="{StaticResource CloseCircleWidth}"
Fill="{TemplateBinding Background}"
Height="{StaticResource CloseCircleWidth}" />
<Canvas Canvas.Left="{StaticResource CloseButtonOffset}"
Canvas.Top="{StaticResource CloseButtonOffset}"
Background="Transparent"
Width="{StaticResource CloseButtonWidth}"
Height="{StaticResource CloseButtonWidth}">
<Line X1="0"
Y1="0"
X2="{StaticResource CloseButtonWidth}"
Y2="{StaticResource CloseButtonWidth}"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="1.5" />
<Line X1="0"
Y1="{StaticResource CloseButtonWidth}"
X2="{StaticResource CloseButtonWidth}"
Y2="0"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="1.5" />
</Canvas>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="#DCDCDD" />
</Trigger>
</Style.Triggers>
</Style>
TabItem shape is calculated via TabShape class. It is hard to make any changes through code.
I think that it would be better if style is given via XAML (possibility to be styled via Blend in future).
I'm trying this on Windows 10, and the ability to snap a window back into tabs doesn't seem to work.
Here is a quick example
Otherwise, this seems quite nice :)
This xaml command is not found on my system
I need a .Net Core package to port my application to .Net Core.
Hey you, i'm very interested your project, so i tried running your demo. Then i find out some problems. Tabs don't dispose when i close, so RAM increase.
I really like this TabControl, but is there a way to persist the VisualTree of the Tabs?
If i switch a Tab the VisualTree will be new generated and it loses all of its sorting settings.
The Problem is really good described here: http://www.codeproject.com/Articles/212233/Persist-the-Visual-Tree-when-switching-tabs-in-the
You can also take a look on Sascha Barbers Comment and his solution: http://www.codeproject.com/Articles/212233/Persist-the-Visual-Tree-when-switching-tabs-in-the?fid=1633690&df=10000&mpp=50&prof=False&sort=Position&view=Thread&spc=Relaxed&select=4702925#xx4702925xx
CloseTabCommand the canExecute is actually ignored. There is now way to prevent the user from closing the last tab using MVVM
I'm trying to apply dark theme in my WPF application. The tabs are not taking the theme color. Can you show me a way how that can be done?
Hi,
I just wanted to find out if this is still alive. I currently have a project (it's on github) that uses the default out of the box wpf tab control and it sucks.
I saw this project and felt that this would be the right fit.
Also will this work when i'm not using MVVM of any kinds?
Please let me know if you want the url to the project (it's not that big) and see if it can be an easy drop-in replacement.
Cheers
Hello,
first of all thank you for this Project. I was able to extend a program with tabs to support multiple views of data.
Anyway, sometimes inside the tabs, Exceptions are thrown which i can't seem to catch. The Program than starts up but doesn't show any tabs. I tried to catch them with AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
but it seems only some are caught.
I built up the Program similar to your Demo and i would intentionally throw an Exception in your TabBase.cs Class to simulate errors (In a getter or setter or even in the constructor where I register commands). Then the Program gets caught up in a kind of empty Tabs state but it doesn't close or anything else where it passes by where I could log that error.
The only thing that comes to my mind is putting a tryCatch around every kind of critical function to log the error.
Do you have an Idea how to handle this properly?
Kind Regards
Inside a TabItem there is a button, originally enabled, and when pressed a message box is shown.
The ChromeTabControl is defined in my MainWindow and the Button is defined in UserControl1, which serves as the view of TabItem. Notice that the CloseCommand of ChromeTabControl left undefined on purpose.
<Window x:Class="playground.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ct="clr-namespace:ChromeTabs;assembly=ChromeTabs"
xmlns:local="clr-namespace:playground"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<DataTemplate DataType="{x:Type local:CustomizedTabClass}">
<local:UserControl1/>
</DataTemplate>
</Window.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top" Text="fixed"/>
<Grid DockPanel.Dock="Bottom" Margin="5">
<ct:ChromeTabControl x:Name="MainTabControl"
ItemsSource="{Binding ItemCollection}"
SelectedItem="{Binding SelectedTab}"
TabPersistBehavior="All">
</ct:ChromeTabControl>
</Grid>
</DockPanel>
</Window>
If I press "close" (as the black rectangle indicates), of course the tab will not be closed, but why is the button disabled?
Great work on the previous issue, I got another problem with this. Hope you can help.
When the view of the tab is very "heavy", fast actions on popping out and reordering tabs throws this error from the MoveTab:
I couldn't reproduce it with your Demo app. I think it has to do with the fact that the tabs I am handling in my app are very heavy and maybe moving the tabs is too slow to react on the changes...?
internal void MoveTab(int fromIndex, int toIndex)
{
if (this.Items.Count == 0 || fromIndex == toIndex)
{
return;
}
object fromTab = this.Items[fromIndex];
System.ArgumentOutOfRangeException was unhandled by user code
HResult=-2146233086
Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source=mscorlib
ParamName=index
StackTrace:
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Windows.Data.ListCollectionView.InternalItemAt(Int32 index)
at ChromeTabs.ChromeTabControl.MoveTab(Int32 fromIndex, Int32 toIndex)
at ChromeTabs.ChromeTabPanel.<>c__DisplayClass8.b__5()
at ChromeTabs.ChromeTabPanel.<>c__DisplayClasse.b__d(Object o, EventArgs ea)
at System.Windows.Media.Animation.Clock.RaiseAccumulatedEvents()
at System.Windows.Media.Animation.TimeManager.RaiseEnqueuedEvents()
at System.Windows.Media.Animation.TimeManager.Tick()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
InnerException:
Hi. I've tab contents with a webview2. The url of the webview2 is bound to a viewmodel. Now when i tear out a tab only the viewmodel is passed along. If a new user control is initialized for that viewmodel, the browser will just create a new instance and load that url, losing the current navigation state. I've looked through the examples and source in depth, but I'm unable to find a solution.
My reasoning so far:
As i'm quite stuck at the moment, any tips would be highly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.