diff --git a/Fabulous.XamarinForms/extensions/FFImageLoading/CachedImage.fs b/Fabulous.XamarinForms/extensions/FFImageLoading/CachedImage.fs index 81827f5e3..ca1982dff 100644 --- a/Fabulous.XamarinForms/extensions/FFImageLoading/CachedImage.fs +++ b/Fabulous.XamarinForms/extensions/FFImageLoading/CachedImage.fs @@ -97,6 +97,9 @@ module FFImageLoadingExtension = let attribCount = match finish with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match success with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match error with Some _ -> attribCount + 1 | None -> attribCount + + // Unbox the ViewRef + let viewRef = match ref with None -> None | Some (ref: ViewRef) -> Some ref.Unbox // Populate the attributes of the base element let attribs = @@ -112,7 +115,7 @@ module FFImageLoadingExtension = ?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor, ?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor, ?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId, - ?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) + ?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) // Add our own attributes. They must have unique names which must match the names below. match source with None -> () | Some v -> attribs.Add (CachedImageSourceAttribKey, v) diff --git a/Fabulous.XamarinForms/extensions/Maps/Xamarin.Forms.Maps.fs b/Fabulous.XamarinForms/extensions/Maps/Xamarin.Forms.Maps.fs index c3e7c973a..dbf7a7244 100644 --- a/Fabulous.XamarinForms/extensions/Maps/Xamarin.Forms.Maps.fs +++ b/Fabulous.XamarinForms/extensions/Maps/Xamarin.Forms.Maps.fs @@ -41,6 +41,9 @@ module MapsExtension = let attribCount = match mapType with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match hasZoomEnabled with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match requestedRegion with Some _ -> attribCount + 1 | None -> attribCount + + // Unbox the ViewRef + let viewRef = match ref with None -> None | Some (ref: ViewRef) -> Some ref.Unbox // Count and populate the inherited attributes let attribs = @@ -56,7 +59,7 @@ module MapsExtension = ?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor, ?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor, ?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId, - ?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) + ?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) // Add our own attributes. They must have unique names which must match the names below. match pins with None -> () | Some v -> attribs.Add(MapPinsAttribKey, v) diff --git a/Fabulous.XamarinForms/extensions/OxyPlot/OxyPlot.fs b/Fabulous.XamarinForms/extensions/OxyPlot/OxyPlot.fs index efd690701..fae969696 100644 --- a/Fabulous.XamarinForms/extensions/OxyPlot/OxyPlot.fs +++ b/Fabulous.XamarinForms/extensions/OxyPlot/OxyPlot.fs @@ -32,6 +32,9 @@ module OxyPlotExtension = // Count the number of additional attributes let attribCount = 1 let attribCount = match controller with Some _ -> attribCount + 1 | None -> attribCount + + // Unbox the ViewRef + let viewRef = match ref with None -> None | Some (ref: ViewRef) -> Some ref.Unbox // Populate the attributes of the base element let attribs = @@ -47,7 +50,7 @@ module OxyPlotExtension = ?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor, ?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor, ?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId, - ?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) + ?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) // Add our own attributes. attribs.Add(ModelAttribKey, model) diff --git a/Fabulous.XamarinForms/extensions/SkiaSharp/SkiaSharp.fs b/Fabulous.XamarinForms/extensions/SkiaSharp/SkiaSharp.fs index 4a26aeb5f..e935d8609 100644 --- a/Fabulous.XamarinForms/extensions/SkiaSharp/SkiaSharp.fs +++ b/Fabulous.XamarinForms/extensions/SkiaSharp/SkiaSharp.fs @@ -34,6 +34,9 @@ module SkiaSharpExtension = let attribCount = match ignorePixelScaling with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match paintSurface with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match touch with Some _ -> attribCount + 1 | None -> attribCount + + // Unbox the ViewRef + let viewRef = match ref with None -> None | Some (ref: ViewRef) -> Some ref.Unbox // Populate the attributes of the base element let attribs = @@ -49,7 +52,7 @@ module SkiaSharpExtension = ?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor, ?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor, ?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId, - ?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) + ?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) // Add our own attributes. They must have unique names which must match the names below. match enableTouchEvents with None -> () | Some v -> attribs.Add(CanvasEnableTouchEventsAttribKey, v) diff --git a/Fabulous.XamarinForms/extensions/VideoManager/VideoManager.fs b/Fabulous.XamarinForms/extensions/VideoManager/VideoManager.fs index 2b5d7e526..201b82e89 100644 --- a/Fabulous.XamarinForms/extensions/VideoManager/VideoManager.fs +++ b/Fabulous.XamarinForms/extensions/VideoManager/VideoManager.fs @@ -32,6 +32,9 @@ module VideoManagerExtension = let attribCount = match source with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match videoAspect with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match showControls with Some _ -> attribCount + 1 | None -> attribCount + + // Unbox the ViewRef + let viewRef = match ref with None -> None | Some (ref: ViewRef) -> Some ref.Unbox // Populate the attributes of the base element let attribs = @@ -47,7 +50,7 @@ module VideoManagerExtension = ?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor, ?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor, ?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId, - ?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) + ?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created) // Add our own attributes. match source with None -> () | Some v -> attribs.Add(SourceAttribKey, v) diff --git a/docs/Fabulous.XamarinForms/views-extending.md b/docs/Fabulous.XamarinForms/views-extending.md index 8b2c22605..5ee79b652 100644 --- a/docs/Fabulous.XamarinForms/views-extending.md +++ b/docs/Fabulous.XamarinForms/views-extending.md @@ -57,9 +57,12 @@ module MyViewExtensions = let attribCount = 0 let attribCount = match prop1 with Some _ -> attribCount + 1 | None -> attribCount let attribCount = match prop2 with Some _ -> attribCount + 1 | None -> attribCount + + // Unbox the ViewRef + let viewRef = match ref with None -> None | Some (ref: ViewRef) -> Some ref.Unbox // Populate the attributes of the base element - let attribs = ViewBuilders.BuildBASE(attribCount, ... inherited attributes ... ) + let attribs = ViewBuilders.BuildBASE(attribCount, ... inherited attributes (with ?ref=viewRef) ... ) // Add our own attributes. match prop1 with None -> () | Some v -> attribs.Add (Prop1AttribKey, v)