From ad1563a0e24798cf6955729773a97b94aba8ec10 Mon Sep 17 00:00:00 2001 From: T Paine Date: Thu, 22 Aug 2019 13:42:48 -0700 Subject: [PATCH] TabView: Visual update (#1192) * Update visuals to match design. Added new event for VectorChanged, fixed unwanted tooltip appearing due to keyboard accelerators. --- dev/Generated/TabView.properties.cpp | 11 +++ dev/Generated/TabView.properties.h | 3 + dev/TabView/TabView.cpp | 4 +- dev/TabView/TabView.idl | 2 + dev/TabView/TabView.xaml | 113 +++++++++++++++++++----- dev/TabView/TabView_themeresources.xaml | 55 ++++++------ dev/TabView/TestUI/TabViewPage.xaml.cs | 2 +- 7 files changed, 143 insertions(+), 47 deletions(-) diff --git a/dev/Generated/TabView.properties.cpp b/dev/Generated/TabView.properties.cpp index 242c94b23c..9cee250d57 100644 --- a/dev/Generated/TabView.properties.cpp +++ b/dev/Generated/TabView.properties.cpp @@ -33,6 +33,7 @@ TabViewProperties::TabViewProperties() , m_tabDragCompletedEventSource{static_cast(this)} , m_tabDragStartingEventSource{static_cast(this)} , m_tabDroppedOutsideEventSource{static_cast(this)} + , m_tabItemsChangedEventSource{static_cast(this)} , m_tabStripDragOverEventSource{static_cast(this)} , m_tabStripDropEventSource{static_cast(this)} { @@ -505,6 +506,16 @@ void TabViewProperties::TabDroppedOutside(winrt::event_token const& token) m_tabDroppedOutsideEventSource.remove(token); } +winrt::event_token TabViewProperties::TabItemsChanged(winrt::TypedEventHandler const& value) +{ + return m_tabItemsChangedEventSource.add(value); +} + +void TabViewProperties::TabItemsChanged(winrt::event_token const& token) +{ + m_tabItemsChangedEventSource.remove(token); +} + winrt::event_token TabViewProperties::TabStripDragOver(winrt::DragEventHandler const& value) { return m_tabStripDragOverEventSource.add(value); diff --git a/dev/Generated/TabView.properties.h b/dev/Generated/TabView.properties.h index 93dc8282c2..63ac06cce1 100644 --- a/dev/Generated/TabView.properties.h +++ b/dev/Generated/TabView.properties.h @@ -108,6 +108,8 @@ class TabViewProperties void TabDragStarting(winrt::event_token const& token); winrt::event_token TabDroppedOutside(winrt::TypedEventHandler const& value); void TabDroppedOutside(winrt::event_token const& token); + winrt::event_token TabItemsChanged(winrt::TypedEventHandler const& value); + void TabItemsChanged(winrt::event_token const& token); winrt::event_token TabStripDragOver(winrt::DragEventHandler const& value); void TabStripDragOver(winrt::event_token const& token); winrt::event_token TabStripDrop(winrt::DragEventHandler const& value); @@ -119,6 +121,7 @@ class TabViewProperties event_source> m_tabDragCompletedEventSource; event_source> m_tabDragStartingEventSource; event_source> m_tabDroppedOutsideEventSource; + event_source> m_tabItemsChangedEventSource; event_source m_tabStripDragOverEventSource; event_source m_tabStripDropEventSource; diff --git a/dev/TabView/TabView.cpp b/dev/TabView/TabView.cpp index ec962a8d12..b0c8832fcc 100644 --- a/dev/TabView/TabView.cpp +++ b/dev/TabView/TabView.cpp @@ -268,8 +268,10 @@ void TabView::OnSizeChanged(const winrt::IInspectable&, const winrt::SizeChanged void TabView::OnItemsChanged(winrt::IInspectable const& item) { - if (auto args = item.as< winrt::IVectorChangedEventArgs>()) + if (auto args = item.as()) { + m_tabItemsChangedEventSource(*this, args); + int numItems = static_cast(TabItems().Size()); if (args.CollectionChange() == winrt::CollectionChange::ItemRemoved && numItems > 0) { diff --git a/dev/TabView/TabView.idl b/dev/TabView/TabView.idl index c9a8734afd..291958eb01 100644 --- a/dev/TabView/TabView.idl +++ b/dev/TabView/TabView.idl @@ -71,6 +71,8 @@ unsealed runtimeclass TabView : Windows.UI.Xaml.Controls.Control event Windows.Foundation.TypedEventHandler AddTabButtonClick; + event Windows.Foundation.TypedEventHandler TabItemsChanged; + // From ListView Object TabItemsSource; Windows.Foundation.Collections.IVector TabItems{ get; }; diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 87e1e90eae..7f68b8fd35 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -3,6 +3,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:contract4Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,4)" + xmlns:contract6Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,6)" + xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:local="using:Microsoft.UI.Xaml.Controls" xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives"> @@ -11,6 +13,7 @@ + @@ -200,14 +203,83 @@