--- /dev/null
+using System.ComponentModel;
+using Xamarin.Forms.Platform.Tizen;
+using Tizen.Xamarin.Forms.Extension;
+using Tizen.Xamarin.Forms.Extension.Renderer;
+using EBackground = ElmSharp.Background;
+using EBackgroundOptions = ElmSharp.BackgroundOptions;
+using TForms = Xamarin.Forms.Platform.Tizen.Forms;
+
+[assembly: ExportRenderer(typeof(Background), typeof(BackgroundRenderer))]
+namespace Tizen.Xamarin.Forms.Extension.Renderer
+{
+ public class BackgroundRenderer : ViewRenderer<Background, EBackground>
+ {
+ public BackgroundRenderer()
+ {
+ }
+
+ protected override void OnElementChanged(ElementChangedEventArgs<Background> e)
+ {
+ if (Control == null)
+ {
+ var background = new EBackground(TForms.Context.MainWindow);
+ SetNativeControl(background);
+ }
+ if (e.NewElement != null)
+ {
+ UpdateImage();
+ UpdateOption();
+ }
+ base.OnElementChanged(e);
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == Background.ImageProperty.PropertyName)
+ {
+ UpdateImage();
+ }
+ else if (e.PropertyName == Background.OptionProperty.PropertyName)
+ {
+ UpdateOption();
+ }
+ base.OnElementPropertyChanged(sender, e);
+ }
+
+ void UpdateImage()
+ {
+ Control.File = ResourcePath.GetPath(Element.Image.File);
+ }
+
+ void UpdateOption()
+ {
+ Control.BackgroundOption = ConvertToNativeBackgroundOptions(((Background)Element).Option);
+ }
+
+ EBackgroundOptions ConvertToNativeBackgroundOptions(BackgroundOptions option)
+ {
+ if (option == BackgroundOptions.Center)
+ {
+ return EBackgroundOptions.Center;
+ }
+ else if (option == BackgroundOptions.Stretch)
+ {
+ return EBackgroundOptions.Stretch;
+ }
+ else if (option == BackgroundOptions.Tile)
+ {
+ return EBackgroundOptions.Tile;
+ }
+ else
+ {
+ return EBackgroundOptions.Scale;
+ }
+ }
+ }
+}
<WarningLevel>4</WarningLevel>\r
</PropertyGroup>\r
<ItemGroup>\r
+ <Compile Include="BackgroundRenderer.cs" />\r
<Compile Include="Cells\DoubleLabelCellRenderer.cs" />\r
<Compile Include="Cells\MultilineCellRenderer.cs" />\r
<Compile Include="Cells\TypeCellRenderer.cs" />\r
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
</PropertyGroup>\r
-</Project>
\ No newline at end of file
+</Project>
--- /dev/null
+using Xamarin.Forms;
+
+namespace Tizen.Xamarin.Forms.Extension
+{
+ public class Background : View
+ {
+ public static readonly BindableProperty ImageProperty = BindableProperty.Create("Image", typeof(FileImageSource), typeof(Background), default(FileImageSource));
+
+ public static readonly BindableProperty OptionProperty = BindableProperty.Create("Option", typeof(BackgroundOptions), typeof(Background), BackgroundOptions.Scale);
+
+ public FileImageSource Image
+ {
+ get { return (FileImageSource)GetValue(ImageProperty); }
+ set { SetValue(ImageProperty, value); }
+ }
+
+ public BackgroundOptions Option
+ {
+ get { return (BackgroundOptions)GetValue(OptionProperty); }
+ set { SetValue(OptionProperty, value); }
+ }
+ }
+}