-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from asklar/userControl
CodeGen for custom winmd files UserControls
- Loading branch information
Showing
42 changed files
with
1,038 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "pch.h" | ||
#include "BlankUserControl.h" | ||
#if __has_include("BlankUserControl.g.cpp") | ||
#include "BlankUserControl.g.cpp" | ||
#endif | ||
|
||
using namespace winrt; | ||
using namespace Windows::UI::Xaml; | ||
|
||
namespace winrt::RuntimeComponent1::implementation | ||
{ | ||
BlankUserControl::BlankUserControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
int32_t BlankUserControl::MyProperty() | ||
{ | ||
auto value = this->GetValue(MyPropertyProperty()); | ||
return winrt::unbox_value<int32_t>(value); | ||
} | ||
|
||
void BlankUserControl::MyProperty(int32_t value) | ||
{ | ||
this->SetValue(MyPropertyProperty(), winrt::box_value(value)); | ||
} | ||
|
||
winrt::event_token BlankUserControl::Happened(Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable> const | ||
& handler) noexcept { | ||
return m_happened.add(handler); | ||
} | ||
void BlankUserControl::Happened(winrt::event_token const& token) { | ||
m_happened.remove(token); | ||
} | ||
|
||
|
||
void BlankUserControl::ClickHandler(IInspectable const&, RoutedEventArgs const&) | ||
{ | ||
auto v = MyProperty() + 1; | ||
MyProperty(v); | ||
Button().Content(box_value(L"Clicked " + std::to_wstring(v))); | ||
|
||
m_happened(*this, nullptr); | ||
} | ||
|
||
winrt::Windows::UI::Xaml::DependencyProperty BlankUserControl::MyPropertyProperty() { | ||
if (m_myPropertyProperty == nullptr) { | ||
auto typeMetadata = PropertyMetadata::Create(winrt::box_value(0), [](const DependencyObject& sender, const DependencyPropertyChangedEventArgs& args) { | ||
if (auto control = sender.try_as<winrt::RuntimeComponent1::BlankUserControl>()) { | ||
auto v = winrt::unbox_value<int32_t>(args.NewValue()); | ||
control.MyProperty(v); | ||
} | ||
}); | ||
m_myPropertyProperty = winrt::Windows::UI::Xaml::DependencyProperty::Register(L"MyProperty", winrt::xaml_typename<int32_t>(), winrt::xaml_typename<winrt::RuntimeComponent1::BlankUserControl>(), typeMetadata); | ||
} | ||
return m_myPropertyProperty; | ||
} | ||
winrt::Windows::UI::Xaml::DependencyProperty BlankUserControl::m_myPropertyProperty = nullptr; | ||
|
||
} | ||
|
Oops, something went wrong.