SHOW:
|
|
- or go back to the newest paste.
| 1 | // Selector.idl | |
| 2 | ||
| 3 | import "Selector.idl"; | |
| 4 | ||
| 5 | namespace TemplateTest | |
| 6 | {
| |
| 7 | [default_interface] | |
| 8 | runtimeclass MainWindow : Microsoft.UI.Xaml.Window | |
| 9 | {
| |
| 10 | MainWindow(); | |
| 11 | Selector Selector; | |
| 12 | } | |
| 13 | } | |
| 14 | ||
| 15 | // Selector.h | |
| 16 | ||
| 17 | #pragma once | |
| 18 | #include "Selector.g.h" | |
| 19 | ||
| 20 | namespace winrt::TemplateTest::implementation | |
| 21 | {
| |
| 22 | struct Selector : SelectorT<Selector> | |
| 23 | {
| |
| 24 | Selector() = default; | |
| 25 | ||
| 26 | Windows::UI::Xaml::DataTemplate SelectTemplateCore(IInspectable const& item, Windows::UI::Xaml::DependencyObject const& container); | |
| 27 | Windows::UI::Xaml::DataTemplate SelectTemplateCore(IInspectable const& item); | |
| 28 | ||
| 29 | winrt::Windows::UI::Xaml::DataTemplate firstTemplate(); | |
| 30 | void firstTemplate(winrt::Windows::UI::Xaml::DataTemplate const& value); | |
| 31 | ||
| 32 | winrt::Windows::UI::Xaml::DataTemplate secondTemplate(); | |
| 33 | void secondTemplate(winrt::Windows::UI::Xaml::DataTemplate const& value); | |
| 34 | ||
| 35 | private: | |
| 36 | Windows::UI::Xaml::DataTemplate mSelector1; | |
| 37 | Windows::UI::Xaml::DataTemplate mSelector2; | |
| 38 | }; | |
| 39 | } | |
| 40 | namespace winrt::TemplateTest::factory_implementation | |
| 41 | {
| |
| 42 | struct Selector : SelectorT<Selector, implementation::Selector> | |
| 43 | {
| |
| 44 | }; | |
| 45 | } | |
| 46 | ||
| 47 | //Selector.cpp | |
| 48 | ||
| 49 | #include "pch.h" | |
| 50 | #include "Selector.h" | |
| 51 | #include "Selector.g.cpp" | |
| 52 | ||
| 53 | namespace winrt::TemplateTest::implementation | |
| 54 | {
| |
| 55 | Windows::UI::Xaml::DataTemplate Selector::SelectTemplateCore(IInspectable const& item, Windows::UI::Xaml::DependencyObject const& container) | |
| 56 | {
| |
| 57 | return mSelector1; | |
| 58 | } | |
| 59 | ||
| 60 | Windows::UI::Xaml::DataTemplate Selector::SelectTemplateCore(IInspectable const& item) | |
| 61 | {
| |
| 62 | return mSelector1; | |
| 63 | } | |
| 64 | ||
| 65 | winrt::Windows::UI::Xaml::DataTemplate Selector::firstTemplate() | |
| 66 | {
| |
| 67 | return this->mSelector1; | |
| 68 | } | |
| 69 | ||
| 70 | void Selector::firstTemplate(winrt::Windows::UI::Xaml::DataTemplate const& value) | |
| 71 | {
| |
| 72 | if (mSelector1 != value) {
| |
| 73 | mSelector1 = value; | |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | winrt::Windows::UI::Xaml::DataTemplate Selector::secondTemplate() | |
| 78 | {
| |
| 79 | return this->mSelector2; | |
| 80 | } | |
| 81 | ||
| 82 | void Selector::secondTemplate(winrt::Windows::UI::Xaml::DataTemplate const& value) | |
| 83 | {
| |
| 84 | if (mSelector2 != value) {
| |
| 85 | mSelector2 = value; | |
| 86 | } | |
| 87 | } | |
| 88 | } | |
| 89 | ||
| 90 | //MainWindow.xaml.h | |
| 91 | ||
| 92 | #pragma once | |
| 93 | ||
| 94 | #include "MainWindow.g.h" | |
| 95 | #include "Selector.h" | |
| 96 | ||
| 97 | namespace winrt::TemplateTest::implementation | |
| 98 | {
| |
| 99 | struct MainWindow : MainWindowT<MainWindow> | |
| 100 | {
| |
| 101 | MainWindow(); | |
| 102 | ||
| 103 | winrt::TemplateTest::Selector Selector(); | |
| 104 | void Selector(winrt::TemplateTest::Selector const& value); | |
| 105 | ||
| 106 | private: | |
| 107 | winrt::TemplateTest::Selector mSelector; | |
| 108 | }; | |
| 109 | } | |
| 110 | ||
| 111 | namespace winrt::TemplateTest::factory_implementation | |
| 112 | {
| |
| 113 | struct MainWindow : MainWindowT<MainWindow, implementation::MainWindow> | |
| 114 | {
| |
| 115 | }; | |
| 116 | } | |
| 117 | ||
| 118 | //MainWindow.xaml.cpp | |
| 119 | ||
| 120 | namespace winrt::TemplateTest::implementation | |
| 121 | {
| |
| 122 | MainWindow::MainWindow() | |
| 123 | {
| |
| 124 | InitializeComponent(); | |
| 125 | } | |
| 126 | ||
| 127 | winrt::TemplateTest::Selector MainWindow::Selector() {
| |
| 128 | return mSelector; | |
| 129 | } | |
| 130 | ||
| 131 | void MainWindow::Selector(winrt::TemplateTest::Selector const& value) {
| |
| 132 | if (mSelector != value) {
| |
| 133 | mSelector = value; | |
| 134 | } | |
| 135 | } | |
| 136 | } | |
| 137 | ||
| 138 | - | //XAML: |
| 138 | + |