框架可见的绑定无效
在最新的.NET MAUI Preview 17.3.0 Preview 2.0中,我对我对绑定的绑定有问题。可能与该版本无关。我没有使用mvvm ..在这里是我的代码:
<Frame Background="LightBlue" IsVisible="{Binding FrameVisible}" x:Name="Frame_Test" Margin="0,10,0,0" CornerRadius="25" HeightRequest="100">
在XAML的后端,我有一个布尔值我试图绑定到
private bool frameVisible;
public bool FrameVisible
{
get
{
return frameVisible;
}
set
{
frameVisible = value;
OnPropertyChanged("FrameVisible");
}
}
InotifiyPropertychang
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
Console.WriteLine($"[App] Property changed {propertyName}");
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
我正在实现我的类构造函数中的 ,我正在设置BindingContext = this; 我想念什么?更改framevisible = false或true之后,OnProperTychanged触发器,但我看不到框架上的GUI更改。悬停在XAML上后的结果显示未找到用于绑定的数据。
I am having an issue with my Binding on isVisible in latest .Net Maui Preview 17.3.0 Preview 2.0. Probably unrelated to the version. I am not using MVVM..here is my code:
<Frame Background="LightBlue" IsVisible="{Binding FrameVisible}" x:Name="Frame_Test" Margin="0,10,0,0" CornerRadius="25" HeightRequest="100">
In the backend of the XAML, I have the boolean I am trying to bind to
private bool frameVisible;
public bool FrameVisible
{
get
{
return frameVisible;
}
set
{
frameVisible = value;
OnPropertyChanged("FrameVisible");
}
}
I am implementing INotifiyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
Console.WriteLine(quot;[App] Property changed {propertyName}");
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
In my class constructor I am setting bindingcontext = this;
What am I missing? The OnPropertyChanged triggers after changing frameVisible = false or true but I don't see any changes on GUI for the frame. The result after hovering over Xaml shows No datacontext found for binding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用边框而不是框架。例子:
Use Border instead of Frame. Example:
当前被错误的
不幸的是,似乎已经合并了一个修复程序。请参阅: https://github.com/dotnet/maui/maui/sissues/8044IsVisible
is currently bugged and not working unfortunately, seems like a fix has been merged. See: https://github.com/dotnet/maui/issues/8044