forked from microsoft/microsoft-ui-xaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavigationViewItemBase.cpp
81 lines (69 loc) · 2.07 KB
/
NavigationViewItemBase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"
#include "common.h"
#include "NavigationViewItemBase.h"
#include "NavigationView.h"
#include "IndexPath.h"
void NavigationViewItemBase::OnApplyTemplate()
{
__super::OnApplyTemplate();
Loaded({ this, &NavigationViewItemBase::OnLoaded });
}
void NavigationViewItemBase::OnLoaded(winrt::IInspectable const&, winrt::RoutedEventArgs const&)
{
// If the NavViewItem is not prepared in an ItemPresenter it will be missing a reference to NavigationView, so adding that here.
if (!m_navigationView.get())
{
SetNavigationViewParent(SharedHelpers::GetAncestorOfType<winrt::NavigationView>(*this));
}
}
NavigationViewRepeaterPosition NavigationViewItemBase::Position() const
{
return m_position;
}
void NavigationViewItemBase::Position(NavigationViewRepeaterPosition value)
{
if (m_position != value)
{
m_position = value;
OnNavigationViewItemBasePositionChanged();
}
}
winrt::NavigationView NavigationViewItemBase::GetNavigationView() const
{
return m_navigationView.get();
}
void NavigationViewItemBase::Depth(int depth)
{
if (m_depth != depth)
{
m_depth = depth;
OnNavigationViewItemBaseDepthChanged();
}
}
int NavigationViewItemBase::Depth() const
{
return m_depth;
}
winrt::SplitView NavigationViewItemBase::GetSplitView() const
{
winrt::SplitView splitView{ nullptr };
auto navigationView = GetNavigationView();
if (navigationView)
{
splitView = winrt::get_self<NavigationView>(navigationView)->GetSplitView();
}
return splitView;
}
void NavigationViewItemBase::SetNavigationViewParent(winrt::NavigationView const& navigationView)
{
m_navigationView = winrt::make_weak(navigationView);
}
void NavigationViewItemBase::OnPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args)
{
if (args.Property() == s_IsSelectedProperty)
{
OnNavigationViewItemBaseIsSelectedChanged();
}
}