Fixed FlyoutItemIsVisible is not working with bindings (#24212)
* Fixed FlyoutItemIsVisible is n ot working with bindings * Correct method naming for OnFlyoutItemIsVisibleChanged * FlyoutItemIsVisible attached property should update bindable property for FlyoutItemIsVisible in BaseShellItem --------- Co-authored-by: Daniel Hindrikes <daniel.hindrikes@cab.se>
This commit is contained in:
Родитель
23ccf19441
Коммит
a15cf9b55a
|
@ -219,6 +219,7 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
|
|||
~override Microsoft.Maui.Controls.Region.Equals(object obj) -> bool
|
||||
~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
|
|
|
@ -424,6 +424,7 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
|
|||
~static Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView>.MapItemTemplate(Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView> handler, Microsoft.Maui.Controls.ItemsView itemsView) -> void
|
||||
~static Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView>.MapVerticalScrollBarVisibility(Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView> handler, Microsoft.Maui.Controls.ItemsView itemsView) -> void
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
|
|
|
@ -418,6 +418,7 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
|
|||
~static Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView>.MapItemTemplate(Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView> handler, Microsoft.Maui.Controls.ItemsView itemsView) -> void
|
||||
~static Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView>.MapVerticalScrollBarVisibility(Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2<TItemsView> handler, Microsoft.Maui.Controls.ItemsView itemsView) -> void
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
|
|
|
@ -205,6 +205,7 @@ Microsoft.Maui.Controls.Shapes.Shape.~Shape() -> void
|
|||
override Microsoft.Maui.Controls.Shapes.Shape.OnBindingContextChanged() -> void
|
||||
~override Microsoft.Maui.Controls.ImageButton.OnPropertyChanged(string propertyName = null) -> void
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
Microsoft.Maui.Controls.ShellNavigationQueryParameters
|
||||
Microsoft.Maui.Controls.ShellNavigationQueryParameters.Add(string! key, object! value) -> void
|
||||
Microsoft.Maui.Controls.ShellNavigationQueryParameters.Add(System.Collections.Generic.KeyValuePair<string!, object!> item) -> void
|
||||
|
|
|
@ -232,6 +232,7 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
|
|||
~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool
|
||||
~static Microsoft.Maui.Controls.Handlers.ShellHandler.MapFlyoutIcon(Microsoft.Maui.Controls.Handlers.ShellHandler handler, Microsoft.Maui.Controls.Shell view) -> void
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
|
|
|
@ -193,6 +193,7 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
|
|||
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.IRadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
|
||||
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.RadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTappedProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
|
|
|
@ -221,6 +221,7 @@ Microsoft.Maui.Controls.Xaml.RequireServiceAttribute
|
|||
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.IRadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
|
||||
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.RadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
|
||||
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable<Microsoft.Maui.Graphics.Rect> rectangles) -> Microsoft.Maui.Controls.Region
|
||||
~static readonly Microsoft.Maui.Controls.BaseShellItem.FlyoutItemIsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> Microsoft.Maui.Controls.BindableProperty
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
@ -57,6 +56,10 @@ namespace Microsoft.Maui.Controls
|
|||
public static readonly BindableProperty IsVisibleProperty =
|
||||
BindableProperty.Create(nameof(IsVisible), typeof(bool), typeof(BaseShellItem), true);
|
||||
|
||||
/// <summary>Bindable property for <see cref="FlyoutItemIsVisible"/>.</summary>
|
||||
public static readonly BindableProperty FlyoutItemIsVisibleProperty =
|
||||
BindableProperty.Create(nameof(FlyoutItemIsVisible), typeof(bool), typeof(BaseShellItem), true, propertyChanged: OnFlyoutItemIsVisibleChanged);
|
||||
|
||||
public BaseShellItem()
|
||||
{
|
||||
DeclaredChildren.CollectionChanged += (_, args) =>
|
||||
|
@ -116,10 +119,11 @@ namespace Microsoft.Maui.Controls
|
|||
set => SetValue(IsVisibleProperty, value);
|
||||
}
|
||||
|
||||
/// <include file="../../../docs/Microsoft.Maui.Controls/BaseShellItem.xml" path="//Member[@MemberName='FlyoutItemIsVisible']/Docs/*" />
|
||||
public bool FlyoutItemIsVisible
|
||||
{
|
||||
get => (bool)GetValue(Shell.FlyoutItemIsVisibleProperty);
|
||||
set => SetValue(Shell.FlyoutItemIsVisibleProperty, value);
|
||||
get => (bool)GetValue(FlyoutItemIsVisibleProperty);
|
||||
set => SetValue(FlyoutItemIsVisibleProperty, value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,6 +229,11 @@ namespace Microsoft.Maui.Controls
|
|||
shellItem.FlyoutIcon = (ImageSource)newValue;
|
||||
}
|
||||
|
||||
static void OnFlyoutItemIsVisibleChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
Shell.SetFlyoutItemIsVisible(bindable, (bool)newValue);
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
base.OnPropertyChanged(propertyName);
|
||||
|
|
|
@ -121,6 +121,9 @@ namespace Microsoft.Maui.Controls
|
|||
element
|
||||
.FindParentOfType<Shell>()
|
||||
?.SendFlyoutItemsChanged();
|
||||
|
||||
if(bindable is BaseShellItem baseShellItem && baseShellItem.FlyoutItemIsVisible != (bool)newValue)
|
||||
baseShellItem.FlyoutItemIsVisible = (bool)newValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Maui.Controls.Sample.Issues.Issue24203"
|
||||
Title="Issue24203">
|
||||
<Shell.FlyoutHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<VerticalStackLayout Padding="20">
|
||||
<Label Text="Value of BindableProperty" />
|
||||
<Label Text="{Binding ShowFlyoutItem}" />
|
||||
</VerticalStackLayout>
|
||||
</DataTemplate>
|
||||
</Shell.FlyoutHeaderTemplate>
|
||||
<ShellContent x:Name="Page1" Title="Page 1" FlyoutItemIsVisible="{Binding ShowFlyoutItem, Mode=TwoWay}">
|
||||
<ContentPage>
|
||||
<ContentView Padding="20">
|
||||
<Label Text="Page 1" />
|
||||
</ContentView>
|
||||
</ContentPage>
|
||||
</ShellContent>
|
||||
|
||||
<MenuItem Text="Toggle FlyoutItem" Command="{Binding ToggleFlyoutItemCommand}" />
|
||||
<MenuItem Text="Toggle FlyoutItem AP" Command="{Binding ToggleFlyoutItemWithAttachedPropertyCommand}" />
|
||||
</Shell>
|
|
@ -0,0 +1,28 @@
|
|||
using System.Windows.Input;
|
||||
|
||||
namespace Maui.Controls.Sample.Issues;
|
||||
|
||||
[Issue(IssueTracker.Github, 24203, "FlyoutItemIsVisible is not working with bindings", PlatformAffected.All)]
|
||||
public partial class Issue24203
|
||||
{
|
||||
public Issue24203()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = this;
|
||||
}
|
||||
|
||||
private bool showFlyoutItem = true;
|
||||
public bool ShowFlyoutItem
|
||||
{
|
||||
get => showFlyoutItem;
|
||||
set
|
||||
{
|
||||
showFlyoutItem = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ToggleFlyoutItemCommand => new Command(() => ShowFlyoutItem = !ShowFlyoutItem);
|
||||
public ICommand ToggleFlyoutItemWithAttachedPropertyCommand => new Command(() => Shell.SetFlyoutItemIsVisible(Page1, !Shell.GetFlyoutItemIsVisible(Page1)));
|
||||
}
|
Загрузка…
Ссылка в новой задаче