XamlServiceProviderCatcher en - Leksiqq/WpfMarkupExtension GitHub Wiki
Attention! This article, as well as this announcement, are automatically translated from Russian.
XamlServiceProviderCatcher class
Used in window resources to further access the corresponding IServiceProvider
type object from code, mainly to call the ProvideValue(...)
method.
Properties
ServiceProvider
- returns the previously saved object of typeIServiceProvider
.
Example
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)