Skip to content

Commit

Permalink
turns out Visibility works exactly like you'd want for a TreeView
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Feb 21, 2024
1 parent b706a6d commit 9300647
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/cascadia/TerminalApp/TasksPaneContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace winrt::TerminalApp::implementation
// FilteredCommand() = default;
// FilteredCommand(const winrt::TerminalApp::PaletteItem& item);

void UpdateFilter(const winrt::hstring& filter) override
void UpdateFilter(const winrt::hstring& filter) override
{
TerminalApp::implementation::FilteredCommand::UpdateFilter(filter);
for (const auto& c : _children)
Expand Down Expand Up @@ -150,9 +150,15 @@ namespace winrt::TerminalApp::implementation
};
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::FilteredTask> Children() { return _children; }

winrt::Windows::UI::Xaml::Visibility Visibility()
{
return (_Filter.empty() || _Weight > 0) ? winrt::Windows::UI::Xaml::Visibility::Visible : winrt::Windows::UI::Xaml::Visibility::Collapsed;
};

private:
winrt::Microsoft::Terminal::Settings::Model::Command _command{ nullptr };
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::FilteredTask> _children{ nullptr };

};
}

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalApp/TasksPaneContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
<DataTemplate x:Key="TaskItemTemplate"
x:DataType="local:FilteredTask">
<mux:TreeViewItem x:Name="rootItem"
ItemsSource="{x:Bind Children}">
ItemsSource="{x:Bind Children}"
Visibility="{x:Bind Visibility}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalPaneContent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace TerminalApp
{
String Input{ get; };
Windows.Foundation.Collections.IObservableVector<FilteredTask> Children { get; };
Windows.UI.Xaml.Visibility Visibility { get; };
}

[default_interface] runtimeclass TasksPaneContent : Windows.UI.Xaml.Controls.UserControl, IPaneContent
Expand Down

0 comments on commit 9300647

Please sign in to comment.