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

Add an action for identifying windows #9523

Merged
33 commits merged into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1c7da00
Rebase all the changes on main
zadjii-msft Feb 25, 2021
97818c6
fix a bug and fix the tests
zadjii-msft Feb 25, 2021
2ec9415
fix tests
zadjii-msft Feb 25, 2021
e13e1e7
Good ole Java
zadjii-msft Feb 25, 2021
136ce6d
finish that test
zadjii-msft Feb 25, 2021
ec97c43
macros are life
zadjii-msft Feb 26, 2021
fa26f7f
THIS NEEDS TO GO TO THE PARENT
zadjii-msft Feb 26, 2021
a391455
Plumb the events up and down
zadjii-msft Feb 26, 2021
001f545
Bind the labels to the actual TerminalPage object
zadjii-msft Mar 1, 2021
9270e0f
bind the name, id down to the actual page
zadjii-msft Mar 1, 2021
1f0dceb
add an action for just identifying one single window
zadjii-msft Mar 1, 2021
e238daa
THIS SHOULD GO TO THE PARENT BRANCH
zadjii-msft Mar 2, 2021
27d12a2
THIS NEEDS TO GO TO THE PARENT
zadjii-msft Feb 26, 2021
9d6f47f
yea you better believe the Toast just worked
zadjii-msft Mar 2, 2021
c202257
feedback from review
zadjii-msft Mar 4, 2021
eaaa204
initial review feedback
zadjii-msft Mar 16, 2021
9f54229
Merge remote-tracking branch 'origin/main' into dev/migrie/f/name-win…
zadjii-msft Mar 16, 2021
bba09e3
Address PR concerns
zadjii-msft Mar 16, 2021
0799a19
Merge branch 'dev/migrie/f/name-windows-3' into dev/migrie/f/identify…
zadjii-msft Mar 17, 2021
1105328
That's better
zadjii-msft Mar 17, 2021
97b4935
Cleanup for review
zadjii-msft Mar 17, 2021
765c969
Merge branch 'dev/migrie/f/name-windows-3' into dev/migrie/f/identify…
zadjii-msft Mar 17, 2021
b66503c
Merge remote-tracking branch 'origin/main' into dev/migrie/f/identify…
zadjii-msft Mar 17, 2021
b7703d2
Merge remote-tracking branch 'origin/main' into dev/migrie/f/identify…
zadjii-msft Mar 17, 2021
d035e50
Merge remote-tracking branch 'origin/main' into dev/migrie/f/identify…
zadjii-msft Mar 17, 2021
d64aa61
Merge remote-tracking branch 'origin/main' into dev/migrie/f/identify…
zadjii-msft Mar 24, 2021
8b6e0bc
I'm overcomplicating this
zadjii-msft Mar 24, 2021
7c775d5
Revert "I'm overcomplicating this"
zadjii-msft Mar 24, 2021
b1b94f6
Mainly: delayload the TeachingTip
zadjii-msft Mar 24, 2021
31cb1b7
This is the thing dustin suggested, and I like it
zadjii-msft Mar 24, 2021
5904c58
This will make @dhowett happy
zadjii-msft Mar 26, 2021
2ff4c60
Merge remote-tracking branch 'origin/main' into dev/migrie/f/identify…
zadjii-msft Mar 30, 2021
ff2ce4b
runformat
zadjii-msft Mar 30, 2021
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
54 changes: 40 additions & 14 deletions src/cascadia/Remoting/Monarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,35 +574,61 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
}

// Method Description:
// - This is an event handler for the IdentifyWindowsRequested event. A
// Peasant may raise that event if they want _all_ windows to identify
// themselves.
// - This will tell each and every peasant to identify themselves. This will
// eventually propagate down to TerminalPage::IdentifyWindow.
// - Helper for doing something on each and every peasant, with no regard
// for if the peasant is living or dead.
// - We'll try calling callback on every peasant.
// - If any single peasant is dead, then we'll call errorCallback, and move on.
// - We're taking an errorCallback here, because the thing we usually want
// to do is TraceLog a message, but TraceLoggingWrite is actually a macro
// that _requires_ the second arg to be a string literal. It can't just be
// a variable.
// Arguments:
// - <unused>
// - callback: The function to call on each peasant
// - errorCallback: The function to call if a peasant is dead.
// Return Value:
// - <none>
void Monarch::_identifyWindows(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
void Monarch::_forAllPeasantsIgnoringTheDead(std::function<void(const Remoting::IPeasant&, const uint64_t)> callback,
std::function<void(const uint64_t)> errorCallback)
{
// Notify all the peasants to display their ID.
for (const auto& [id, p] : _peasants)
{
try
{
p.DisplayWindowId();
callback(p, id);
}
catch (...)
{
LOG_CAUGHT_EXCEPTION();
// If this fails, we don't _really_ care. Just move on to the
// next one. Someone else will clean up the dead peasant.
TraceLoggingWrite(g_hRemotingProvider,
"Monarch_identifyWindows_Failed",
TraceLoggingInt64(id, "peasantID", "The ID of the peasant which we could not identify"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
errorCallback(id);
}
}
}

// Method Description:
// - This is an event handler for the IdentifyWindowsRequested event. A
// Peasant may raise that event if they want _all_ windows to identify
// themselves.
// - This will tell each and every peasant to identify themselves. This will
// eventually propagate down to TerminalPage::IdentifyWindow.
// Arguments:
// - <unused>
// Return Value:
// - <none>
void Monarch::_identifyWindows(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
// Notify all the peasants to display their ID.
auto callback = [](auto&& p, auto&& /*id*/) {
p.DisplayWindowId();
};
Comment on lines +623 to +625
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait... if we're not using id, should we just remove it from the first param in _forAllPeasantsIgnoringTheDead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike: writes generic function

Reviewers: is it possibly too generic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, I presumed a future user of this helper might want it.

auto onError = [](auto&& id) {
TraceLoggingWrite(g_hRemotingProvider,
"Monarch_identifyWindows_Failed",
TraceLoggingInt64(id, "peasantID", "The ID of the peasant which we could not identify"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
};
_forAllPeasantsIgnoringTheDead(callback, onError);
}
}
2 changes: 2 additions & 0 deletions src/cascadia/Remoting/Monarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
void _identifyWindows(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);

void _forAllPeasantsIgnoringTheDead(std::function<void(const winrt::Microsoft::Terminal::Remoting::IPeasant&, const uint64_t)> callback,
std::function<void(const uint64_t)> errorCallback);
friend class RemotingUnitTests::RemotingTests;
};
}
Expand Down
4 changes: 0 additions & 4 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,4 @@ namespace winrt::TerminalApp::implementation
_root->WindowId(id);
}
}
// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
// These macros will define them both for you.
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(AppLogic, RequestedThemeChanged, _requestedThemeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::ElementTheme);
}
10 changes: 7 additions & 3 deletions src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,13 @@
<data name="CommandPalette_MoreOptions.[using:Windows.UI.Xaml.Automation]AutomationProperties.HelpText" xml:space="preserve">
<value>More options</value>
</data>
<data name="WindowIdPrefix" xml:space="preserve">
<value>Window: {}</value>
<comment>{} will be replaced with a number identifying this window</comment>
<data name="WindowIdLabel" xml:space="preserve">
<value>Window</value>
<comment>This is displayed as a label for a number, like "Window: 10"</comment>
</data>
<data name="UnnamedWindowName" xml:space="preserve">
<value>unnamed window</value>
<comment>text used to identify when a window hasn't been assigned a name by the user</comment>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<comment>text used to identify when a window hasn't been assigned a name by the user</comment>
<comment>Text used to identify when a window hasn't been assigned a name by the user</comment>

</data>
<data name="WindowMaximizeButtonToolTip" xml:space="preserve">
<value>Maximize</value>
Expand Down
8 changes: 0 additions & 8 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@
<ClInclude Include="MinMaxCloseControl.h">
<DependentUpon>MinMaxCloseControl.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="WindowNameConverter.h">
<DependentUpon>TerminalPage.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="PaletteItemTemplateSelector.h">
<DependentUpon>PaletteItemTemplateSelector.idl</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -157,10 +153,6 @@
<ClCompile Include="MinMaxCloseControl.cpp">
<DependentUpon>MinMaxCloseControl.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="WindowNameConverter.cpp">
<DependentUpon>TerminalPage.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="PaletteItemTemplateSelector.cpp">
<DependentUpon>PaletteItemTemplateSelector.idl</DependentUpon>
<SubType>Code</SubType>
Expand Down
104 changes: 79 additions & 25 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,9 @@ namespace winrt::TerminalApp::implementation

_isAlwaysOnTop = _settings.GlobalSettings().AlwaysOnTop();

// This lambda is a local because there will be more toasts in the
// future that will need the same logic.
auto safeRefocus = [weakThis{ get_weak() }](auto&&, auto&&) {
if (auto page{ weakThis.get() })
{
page->_FocusActiveControl(nullptr, nullptr);
}
};

_windowIdToast = std::make_unique<Toast>(WindowIdToast());
WindowIdToast().Closed(safeRefocus);
// DON'T set up Toasts/TeachingTips here. They should be loaded and
// initialized the first time they're opened, in whatever method opens
// them.

// Setup mouse vanish attributes
SystemParametersInfoW(SPI_GETMOUSEVANISH, 0, &_shouldMouseVanish, false);
Expand Down Expand Up @@ -3025,8 +3017,8 @@ namespace winrt::TerminalApp::implementation
return {};
}

void TerminalPage::_FocusActiveControl(const IInspectable& /*sender*/,
const RoutedEventArgs& /*eventArgs*/)
void TerminalPage::_FocusActiveControl(IInspectable /*sender*/,
IInspectable /*eventArgs*/)
{
// We don't want to set focus on the tab if fly-out is open as it will be closed
// TODO GH#5400: consider checking we are not in the opening state, by hooking both Opening and Open events
Expand Down Expand Up @@ -3375,19 +3367,81 @@ namespace winrt::TerminalApp::implementation
co_await winrt::resume_foreground(Dispatcher());
if (auto page{ weakThis.get() })
{
page->_windowIdToast->Open();
// If we haven't ever loaded the TeachingTip, then do so now and
// create the toast for it.
if (page->_windowIdToast == nullptr)
{
if (MUX::Controls::TeachingTip tip{ page->FindName(L"WindowIdToast").try_as<MUX::Controls::TeachingTip>() })
{
page->_windowIdToast = std::make_shared<Toast>(tip);
// Make sure to use the weak ref when setting up this
// callback.
tip.Closed({ page->get_weak(), &TerminalPage::_FocusActiveControl });
}
}

if (page->_windowIdToast != nullptr)
{
page->_windowIdToast->Open();
}
}
}

// WindowName is a otherwise generic WINRT_OBSERVABLE_PROPERTY, but it needs
// to raise a PropertyChanged for WindowNameForDisplay, instead of
// WindowName.
winrt::hstring TerminalPage::WindowName() const noexcept
{
return _WindowName;
}
void TerminalPage::WindowName(const winrt::hstring& value)
{
if (_WindowName != value)
{
_WindowName = value;
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"WindowNameForDisplay" });
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably set up a PropertyChangedHandler in the ctor and listen for WindowName changed, then fire a WindowNameForDisplay changed event. But like, it probably ends up being the same amount of work as this haha. This is just an option if you really wanted to keep the WINRT_OBSERVABLE_PROPERTY

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, yea, I decided against that b/c I thought at runtime, that would end up being less performant (raise one event, handle it, raise another), rather than just skipping the step.


// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
// These macros will define them both for you.
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, TitleChanged, _titleChangeHandlers, winrt::Windows::Foundation::IInspectable, winrt::hstring);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, LastTabClosed, _lastTabClosedHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, SetTitleBarContent, _setTitleBarContentHandlers, winrt::Windows::Foundation::IInspectable, UIElement);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, FocusModeChanged, _focusModeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, FullscreenChanged, _fullscreenChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, AlwaysOnTopChanged, _alwaysOnTopChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, RaiseVisualBell, _raiseVisualBellHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, SetTaskbarProgress, _setTaskbarProgressHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
// WindowId is a otherwise generic WINRT_OBSERVABLE_PROPERTY, but it needs
// to raise a PropertyChanged for WindowIdForDisplay, instead of
// WindowId.
uint64_t TerminalPage::WindowId() const noexcept
{
return _WindowId;
}
void TerminalPage::WindowId(const uint64_t& value)
{
if (_WindowId != value)
{
_WindowId = value;
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"WindowIdForDisplay" });
}
}

// Method Description:
// - Returns a label like "Window: 1234" for the ID of this window
// Arguments:
// - <none>
// Return Value:
// - a string for displaying the name of the window.
winrt::hstring TerminalPage::WindowIdForDisplay() const noexcept
{
return winrt::hstring{ fmt::format(L"{}: {}",
std::wstring_view(RS_(L"WindowIdLabel")),
_WindowId) };
}

// Method Description:
// - Returns a label like "<unnamed window>" when the window has no name, or the name of the window.
// Arguments:
// - <none>
// Return Value:
// - a string for displaying the name of the window.
winrt::hstring TerminalPage::WindowNameForDisplay() const noexcept
{
return _WindowName.empty() ?
winrt::hstring{ fmt::format(L"<{}>", RS_(L"UnnamedWindowName")) } :
_WindowName;
}
}
36 changes: 23 additions & 13 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,29 @@ namespace winrt::TerminalApp::implementation
const bool initial,
const winrt::hstring cwd = L"");

// Normally, WindowName and WindowId would be
// WINRT_OBSERVABLE_PROPERTY's, but we want them to raise
// WindowNameForDisplay and WindowIdForDisplay instead
winrt::hstring WindowName() const noexcept;
void WindowName(const winrt::hstring& value);
uint64_t WindowId() const noexcept;
void WindowId(const uint64_t& value);
winrt::hstring WindowIdForDisplay() const noexcept;
winrt::hstring WindowNameForDisplay() const noexcept;

WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, WindowName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(uint64_t, WindowId, _PropertyChangedHandlers);

// -------------------------------- WinRT Events ---------------------------------
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangeHandlers, winrt::Windows::Foundation::IInspectable, winrt::hstring);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(LastTabClosed, _lastTabClosedHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTitleBarContent, _setTitleBarContentHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::UIElement);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(FocusModeChanged, _focusModeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(FullscreenChanged, _fullscreenChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(AlwaysOnTopChanged, _alwaysOnTopChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(RaiseVisualBell, _raiseVisualBellHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTaskbarProgress, _setTaskbarProgressHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(Initialized, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::RoutedEventArgs);
TYPED_EVENT(IdentifyWindowsRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable);
TYPED_EVENT(TitleChanged, IInspectable, winrt::hstring);
TYPED_EVENT(LastTabClosed, IInspectable, winrt::TerminalApp::LastTabClosedEventArgs);
TYPED_EVENT(SetTitleBarContent, IInspectable, winrt::Windows::UI::Xaml::UIElement);
TYPED_EVENT(FocusModeChanged, IInspectable, IInspectable);
TYPED_EVENT(FullscreenChanged, IInspectable, IInspectable);
TYPED_EVENT(AlwaysOnTopChanged, IInspectable, IInspectable);
TYPED_EVENT(RaiseVisualBell, IInspectable, IInspectable);
TYPED_EVENT(SetTaskbarProgress, IInspectable, IInspectable);
TYPED_EVENT(Initialized, IInspectable, winrt::Windows::UI::Xaml::RoutedEventArgs);
TYPED_EVENT(IdentifyWindowsRequested, IInspectable, IInspectable);

private:
friend struct TerminalPageT<TerminalPage>; // for Xaml to bind events
Expand Down Expand Up @@ -130,6 +138,8 @@ namespace winrt::TerminalApp::implementation
bool _isInFocusMode{ false };
bool _isFullscreen{ false };
bool _isAlwaysOnTop{ false };
winrt::hstring _WindowName{};
uint64_t _WindowId{ 0 };

bool _rearranging;
std::optional<int> _rearrangeFrom;
Expand Down Expand Up @@ -268,7 +278,7 @@ namespace winrt::TerminalApp::implementation

void _CompleteInitialization();

void _FocusActiveControl(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void _FocusActiveControl(IInspectable sender, IInspectable eventArgs);

void _UnZoomIfNeeded();

Expand Down
14 changes: 2 additions & 12 deletions src/cascadia/TerminalApp/TerminalPage.idl
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ namespace TerminalApp
Windows.Foundation.IAsyncOperation<Windows.UI.Xaml.Controls.ContentDialogResult> ShowDialog(Windows.UI.Xaml.Controls.ContentDialog dialog);
};

runtimeclass WindowIdConverter : [default] Windows.UI.Xaml.Data.IValueConverter
{
WindowIdConverter();
};


runtimeclass WindowNameConverter : [default] Windows.UI.Xaml.Data.IValueConverter
{
WindowNameConverter();
};


[default_interface] runtimeclass TerminalPage : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged
{
TerminalPage();
Expand All @@ -37,6 +25,8 @@ namespace TerminalApp
void IdentifyWindow();
String WindowName;
UInt64 WindowId;
String WindowNameForDisplay { get; };
String WindowIdForDisplay { get; };

// We cannot use the default XAML APIs because we want to make sure
// that there's only one application-global dialog visible at a time,
Expand Down
12 changes: 3 additions & 9 deletions src/cascadia/TerminalApp/TerminalPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ the MIT License. See LICENSE in the project root for license information. -->
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<ResourceDictionary>
<local:WindowIdConverter x:Key="WindowIdConverter"/>
<local:WindowNameConverter x:Key="WindowNameConverter"/>
</ResourceDictionary>
</Page.Resources>

<Grid x:Name="Root" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down Expand Up @@ -144,9 +137,10 @@ the MIT License. See LICENSE in the project root for license information. -->
dismiss itself if the window is unfocused (In Xaml Islands). This is
tracked by MUX#4382-->
<mux:TeachingTip x:Name="WindowIdToast"
x:Load="False"
IsLightDismissEnabled="True"
Title="{x:Bind WindowId, Mode=OneWay, Converter={StaticResource WindowIdConverter}}"
Subtitle="{x:Bind WindowName, Mode=OneWay, Converter={StaticResource WindowNameConverter}}">
Title="{x:Bind WindowIdForDisplay}"
Subtitle="{x:Bind WindowNameForDisplay}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need Mode=OneWay here? I guess it's fine for Window ID because that only gets set once per instance, but once renaming goes in, we'll need to make Window Name Mode=OneWay, right?

Copy link
Member Author

@zadjii-msft zadjii-msft Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, since WindowNameForDisplay only has a getter, and I'm using a totally different toast for renaming

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, OneWay means "listen to PropertyChanged and call the Getter again when it happens"

TwoWay means "this control can call the setter"

The default is OneTime, which is "Call the getter when constructed." 😄

</mux:TeachingTip>
</Grid>
</Page>
Loading