-
Notifications
You must be signed in to change notification settings - Fork 0
XamlServiceProviderCatcher en
Leksiqq edited this page Jul 20, 2024
·
3 revisions
Attention! This article, as well as this announcement, are automatically translated from Russian.
Used in window resources to further access the corresponding IServiceProvider
type object from code, mainly to call the ProvideValue(...)
method.
-
ServiceProvider
- returns the previously saved object of typeIServiceProvider
.
In the MainWindow.xaml
resource dictionary:
<window...
xmlns:l="clr-namespace:Net.Leksi.WpfMarkup;assembly=Net.Leksi.WpfMarkupExtension"
>
<Window.Resources>
<ResourceDictionary>
...
<l:XamlServiceProviderCatcher x:Key="SPC"/>
...
</ResourceDictionary>
</Window.Resources>
In MainWindow.xaml.cs
:
...
ParameterizedResourceExtension pre = new("ValueCellTemplate");
pre.Replaces = new string[] { $"$path:{path}" };
datatemplate? template = pre.ProvideValue((FindResource("SPC") as XamlServiceProviderCatcher)!) as DataTemplate;
...
Before: (ParameterizedResource) Start:(Overview) Next:(BindingProxy)