@@ -507,6 +507,30 @@ public static TDependencyObject BindCommandWithString<TDependencyObject>(
507
507
return target ;
508
508
}
509
509
510
+ public static TDependencyObject StaticResource < TDependencyObject , TPropertyValue > (
511
+ this DependencyProperty < TDependencyObject , TPropertyValue > property ,
512
+ System . Windows . FrameworkElement element ,
513
+ string key
514
+ ) where TDependencyObject : DependencyObject
515
+ => property . Set ( ( TPropertyValue ) element . FindResource ( key ) ) ;
516
+ // TODO: need to set e.g. page resources in C# from either XAML or C#, before Build() is invoked -
517
+ // but then why use a resource? we can use named static fields. Unless we want to reuse an app level xaml resource
518
+
519
+ public static TDependencyObject DynamicResource < TDependencyObject , TPropertyValue > (
520
+ this DependencyProperty < TDependencyObject , TPropertyValue > property ,
521
+ System . Windows . FrameworkElement element ,
522
+ string key
523
+ ) where TDependencyObject : DependencyObject
524
+ { element . SetResourceReference ( property . UI , key ) ; return property . Target ; }
525
+ // TODO: verify this will work for resources added in the parents after reparenting and after updating the parent resources
526
+
527
+ // Correct order: do the resource lookups after OnInitalized is called on the page
528
+ // 1) Content attaches onitialised event handler.
529
+
530
+ // Purpose of resource dictionaries:
531
+ // - reuse of XAML resources in C# page => application resources => (cast)Application.Current.Resources["key"]
532
+ // ? reuse of C# in XAML page?
533
+
510
534
public static TDependencyObject Assign < TDependencyObject , TUI > ( this TDependencyObject bindable , out TUI ui )
511
535
where TDependencyObject : DependencyObject , IUI < TUI >
512
536
where TUI : System . Windows . DependencyObject
0 commit comments