2016-03-22 23:02:25 +03:00
|
|
|
using System;
|
2016-11-15 22:39:48 +03:00
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
namespace Xamarin.Forms.Xaml
|
|
|
|
{
|
|
|
|
[ContentProperty("Path")]
|
2017-02-24 11:10:11 +03:00
|
|
|
[AcceptEmptyServiceProvider]
|
2016-03-22 23:02:25 +03:00
|
|
|
public sealed class BindingExtension : IMarkupExtension<BindingBase>
|
|
|
|
{
|
|
|
|
public BindingExtension()
|
|
|
|
{
|
|
|
|
Mode = BindingMode.Default;
|
|
|
|
Path = Binding.SelfPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Path { get; set; }
|
|
|
|
|
|
|
|
public BindingMode Mode { get; set; }
|
|
|
|
|
|
|
|
public IValueConverter Converter { get; set; }
|
|
|
|
|
|
|
|
public object ConverterParameter { get; set; }
|
|
|
|
|
|
|
|
public string StringFormat { get; set; }
|
|
|
|
|
|
|
|
public object Source { get; set; }
|
|
|
|
|
2016-09-08 21:39:05 +03:00
|
|
|
public string UpdateSourceEventName { get; set; }
|
|
|
|
|
2016-11-15 22:39:48 +03:00
|
|
|
public TypedBindingBase TypedBinding { get; set; }
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
|
|
|
|
{
|
2016-11-15 22:39:48 +03:00
|
|
|
if (TypedBinding == null)
|
|
|
|
return new Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) { UpdateSourceEventName = UpdateSourceEventName };
|
|
|
|
|
|
|
|
TypedBinding.Mode = Mode;
|
|
|
|
TypedBinding.Converter = Converter;
|
|
|
|
TypedBinding.ConverterParameter = ConverterParameter;
|
|
|
|
TypedBinding.StringFormat = StringFormat;
|
|
|
|
TypedBinding.Source = Source;
|
|
|
|
TypedBinding.UpdateSourceEventName = UpdateSourceEventName;
|
|
|
|
return TypedBinding;
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
|
|
|
|
{
|
|
|
|
return (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|