Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ItemsSourceView.IndexOf to public #2231

Merged
merged 3 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4395,8 +4395,7 @@ int NavigationView::GetIndexFromItem(const winrt::ItemsRepeater& ir, const winrt
{
if (auto itemsSourceView = ir.ItemsSourceView())
{
auto inspectingDataSource = static_cast<InspectingDataSource*>(winrt::get_self<ItemsSourceView>(itemsSourceView));
return inspectingDataSource->IndexOf(data);
return itemsSourceView.IndexOf(data);
}
}
return -1;
Expand Down
5 changes: 1 addition & 4 deletions dev/NavigationView/TopNavigationViewDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "Vector.h"
#include "SplitDataSourceBase.h"
#include "TopNavigationViewDataProvider.h"
#include "InspectingDataSource.h"
#include "NavigationViewItem.h"

TopNavigationViewDataProvider::TopNavigationViewDataProvider(const ITrackerHandleManager* m_owner)
Expand Down Expand Up @@ -69,9 +68,7 @@ int TopNavigationViewDataProvider::IndexOf(const winrt::IInspectable& value)
{
if (auto dataSource = m_dataSource.get())
{
auto inspectingDataSource = static_cast<InspectingDataSource*>(winrt::get_self<ItemsSourceView>(dataSource));

return inspectingDataSource->IndexOf(value);
return dataSource.IndexOf(value);
}
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions dev/RadioButtons/RadioButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "RuntimeProfiler.h"
#include "ResourceAccessor.h"
#include "RadioButtonsTestHooks.h"
#include <InspectingDataSource.h>

RadioButtons::RadioButtons()
{
Expand Down Expand Up @@ -537,10 +536,7 @@ void RadioButtons::UpdateSelectedItem()
{
if (auto const itemsSourceView = repeater.ItemsSourceView())
{
if (auto const inspectingDataSource = static_cast<InspectingDataSource*>(winrt::get_self<ItemsSourceView>(itemsSourceView)))
{
Select(inspectingDataSource->IndexOf(SelectedItem()));
}
Select(itemsSourceView.IndexOf(SelectedItem()));
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions dev/Repeater/InspectingDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,6 @@ int InspectingDataSource::IndexOfCore(winrt::IInspectable const& value)

#pragma endregion

int InspectingDataSource::IndexOf(winrt::IInspectable const& value)
{
int index = -1;
if (m_vector && value)
{
auto v = static_cast<uint32_t>(-1);
if (m_vector.get().IndexOf(value, v))
{
index = static_cast<int>(v);
}
}
return index;
}

winrt::IVector<winrt::IInspectable>
InspectingDataSource::WrapIterable(const winrt::IIterable<winrt::IInspectable>& iterable)
{
Expand Down
3 changes: 0 additions & 3 deletions dev/Repeater/InspectingDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class InspectingDataSource :
int IndexOfCore(winrt::IInspectable const& value);
#pragma endregion

// This line can be deleted as soon as the API of ItemsSourceView is public
int IndexOf(winrt::IInspectable const& value);

private:
winrt::Collections::IVector<winrt::IInspectable>
WrapIterable(const winrt::Collections::IIterable<winrt::IInspectable>& iterable);
Expand Down
6 changes: 1 addition & 5 deletions dev/Repeater/ItemsRepeater.idl
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ unsealed runtimeclass ItemsSourceView: Windows.UI.Xaml.Interop.INotifyCollection
Boolean HasKeyIndexMapping{ get; };
String KeyFromIndex(Int32 index);
Int32 IndexFromKey(String key);

[WUXC_VERSION_PREVIEW]
{
Int32 IndexOf(IInspectable item);
}
Int32 IndexOf(IInspectable item);
marcelwgn marked this conversation as resolved.
Show resolved Hide resolved
}

[WUXC_VERSION_MUXONLY]
Expand Down