확실하지. 나는이 작동하는 방법을 간단한 예제를 만들었어요 - 페이지의 XAML :
<Page.Resources>
<local:NullableToBool x:Key="NullConverter"/>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="400" Height="200">
<ProgressRing Width="100" Height="100" Margin="50" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Visible"
IsActive="{x:Bind TheButton.IsChecked, Mode=OneWay, Converter={StaticResource NullConverter}}"/>
<Button Content="Show flyout" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="50">
<Button.Flyout>
<Flyout>
<Border Background="Gray" IsHitTestVisible="{x:Bind IsActive, Mode=OneWay}" Opacity="{x:Bind FlyoutOpacity, Mode=OneWay}">
<ToggleButton Margin="20" x:Name="TheButton" IsChecked="False" Click="TheButton_Click" Content="Doing smth" Width="100"/>
</Border>
</Flyout>
</Button.Flyout>
</Button>
</Grid>
뒤에 코드 :
public class NullableToBool : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return value is bool ? (bool)value : false;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
public sealed partial class MainPage : Page, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void RaiseProperty(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
private bool isActive = true;
public bool IsActive
{
get { return isActive; }
set { isActive = value; RaiseProperty(nameof(IsActive)); }
}
private double flyoutOpacity = 1.0;
public double FlyoutOpacity
{
get { return flyoutOpacity; }
set { flyoutOpacity = value; RaiseProperty(nameof(FlyoutOpacity)); }
}
public MainPage()
{
this.InitializeComponent();
}
private async void TheButton_Click(object sender, RoutedEventArgs e)
{
IsActive = false;
FlyoutOpacity = 0.1;
await Task.Delay(3000);
IsActive = true;
FlyoutOpacity = 1.0;
(sender as ToggleButton).IsChecked = false;
}
}