【发布时间】:2020-10-30 18:17:02
【问题描述】:
我正在编写一个 Xamarin Forms 应用程序,并将我的 XAML 控件的各种属性绑定到我的所有页面共享的公共类结构。为了通知我的代码当前在首页上显示了哪些控件,我触发了一个事件并在处理程序中确定该控件是否可见。 我想用一个不属于类结构的局部变量来触发事件。
<mr:Image ClassId="3" Source="{Binding ImagesDictionary[AudioOnOff],Converter={StaticResource imageFileToImageSourceConverter}}"
PropertyChanged="Image_PropertyChanged"
Opacity="{Binding CtrlTrigger}"
Down="Control_Image_Tapped"
InputTransparent="{Binding InhibitTouch}" />
c#
public partial class HomePage : ContentPage, INotifyPropertyChanged
{
public double CtrlTrigger; // I'll connect this to a notify event, understood.
protected override void OnAppearing()
{
BindingContext = MainPage.CabinData;
}
}
如何将 Opacity 属性仅绑定到 HomePage 中的 CtrlTrigger 双精度,同时允许将 Image 的其他属性绑定到由 Binding 上下文设置的 MainPage.CabinData 类?
【问题讨论】:
标签: xamarin data-binding