{"id":285067,"date":"2017-04-17T12:09:05","date_gmt":"2017-04-17T08:09:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285067"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285067","title":{"rendered":"\u0423\u043f\u0440\u043e\u0449\u0430\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0434\u043b\u044f WPF"},"content":{"rendered":"<p>\u041e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 WPF \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u0432 \u043d\u0435\u043c \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0431\u0435\u0448\u0438\u0432\u0430\u044e\u0442. \u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u2014 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b. \u0420\u0430\u0434\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0438\u0445\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0433\u0434\u0435-\u0442\u043e \u0432 \u043d\u0435\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 Ctrl+F \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f. \u0412 \u043c\u0443\u043b\u044c\u0442\u0438-\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430\u0445 \u0442\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0430\u043c \u0447\u0435\u0440\u0442 \u0437\u0430\u043f\u0443\u0442\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442 MVVM, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0447\u0443\u0434\u043e \u043d\u0430\u0443\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e. \u0427\u0442\u043e-\u0436\u0435, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0440\u0443\u0442\u0438\u043d\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u0432, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 <b>BooleanToVisibilityConverter<\/b> \u0438 \u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445, \u0438\u0445 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u041d\u043e \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u0446\u0435\u043b\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f. \u0418 \u0434\u043e\u043b\u0433\u043e \u044d\u0442\u043e, \u0438 \u0437\u0430\u0441\u043e\u0440\u044f\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0432\u044b\u0438\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u0432\u043e \u0432\u0441\u0435\u043c \u044d\u0442\u043e\u043c \u043c\u0443\u0441\u043e\u0440\u0435.<\/p>\n<p>  \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 binding-\u0430\u043c\u0438 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u043c \u0438\u043b\u0438 \u0434\u0432\u0443\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 (\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0436\u0438\u043c\u0430 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430). \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432 \u2014 \u0441 \u043e\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c. \u0417\u0430 \u043d\u0438\u0445 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b <b>IValueConverter<\/b> \u0438 <b>IMultiValueConverter<\/b> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u041f\u0440\u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0438, \u043e\u0431\u044b\u0447\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0435 \u0432 XAML \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 <b>BindingBase<\/b>:<\/p>\n<pre><code class=\"xml\">&lt;TextBlock Text=&quot;{Binding IntProp, Converter={StaticResource conv:IntToStringConverter}, ConverterParameter=plusOne}&quot; \/&gt; <\/code><\/pre>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0443\u043b\u044c\u0442\u0438-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f:  <\/p>\n<pre><code class=\"xml\">&lt;TextBlock&gt; \t&lt;TextBlock.Text&gt; \t\t&lt;MultiBinding \t\t\tConverter=&quot;{StaticResource conv:IntToStringConverter}&quot; \t\t\tConverterParameter=&quot;plusOne&quot;&gt; \t\t\t&lt;Binding Path=&quot;IntProp&quot; \/&gt; \t\t\t&lt;Binding Path=&quot;StringProp&quot; \/&gt; \t\t&lt;\/MultiBinding&gt; \t&lt;\/TextBlock.Text&gt; &lt;\/TextBlock&gt; <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (\u0422\u0443\u0442 \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u043e-\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438):<\/p>\n<pre><code class=\"cs\">public class IntToStringConverter : IValueConverter, IMultiValueConverter { \tpublic object Convert(object value, Type targetType, object parameter, CultureInfo culture) \t  =&gt; (string)parameter == &quot;plusOne&quot; ? ((int)value + 1).ToString() : value.ToString();  \tpublic object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) \t  =&gt; throw new NotImplementedException();  \tpublic object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) \t =&gt; $&quot;{Convert(values[0], targetType, parameter, culture) as string} {values[1]}&quot;;  \tpublic object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) \t  =&gt; throw new NotImplementedException(); } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u043d\u043e \u0443\u0436\u0435 \u0442\u0443\u0442 \u0431\u0435\u0437 \u043f\u043e\u043b \u043b\u0438\u0442\u0440\u0430 \u043d\u0438 \u0447\u0435\u0440\u0442\u0430 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0437\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0447\u0442\u043e \u0437\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043b\u0435\u0432\u044b\u0435 targetType \u0438 culture, \u0447\u0442\u043e \u0437\u0430 ConvertBack \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0418\u0434\u0435\u0439 \u043f\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<ol>\n<li>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0432 \u0432\u0438\u0434\u0435 \u043a\u0443\u0441\u043a\u043e\u0432 c# \u043a\u043e\u0434\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 xaml \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439;<\/li>\n<li>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 code-behind, \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438\/\u0447\u0430\u0441\u0442\u043d\u044b\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u044d\u0442\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u0433\u0434\u0435-\u043b\u0438\u0431\u043e \u0435\u0449\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c;<\/li>\n<li>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0432 \u0432\u0438\u0434\u0435 \u0442\u043e\u0433\u043e-\u0436\u0435 \u0441\u0430\u043c\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0442\u0430\u043a \u0441\u0442\u0440\u0435\u043c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043b\u0435\u0437\u0442\u044c \u0432 \u0433\u0443\u0433\u043b \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430.<\/li>\n<\/ol>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043e\u0431\u043b\u043e\u043c\u0430\u044e \u0442\u0435\u0445 \u0438\u0437 \u0432\u0430\u0441, \u043a\u0442\u043e \u0434\u0443\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u043d\u043a\u0442 1. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443. \u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"http:\/\/www.ikriv.com\/dev\/wpf\/MathConverter\/index.shtml\">\u0442\u0443\u0442<\/a>. \u0422\u0430\u043a\u0436\u0435 \u044f \u0432\u0438\u0434\u0435\u043b \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0441 expression tree \u0438 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e. \u0422\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u2014 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0442\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u0442\u043e \u0432\u044b\u043b\u0435\u0437\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0438 xml \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f namespace-\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>  \u0410 \u0432\u043e\u0442 2 \u0438 3 \u043f\u0443\u043d\u043a\u0442\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432 code-behind. \u041a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c? \u042f \u0434\u0443\u043c\u0430\u044e \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">private string ConvertIntToString(int intValue, string options)   =&gt; options == &quot;plusOne&quot; ? (intValue + 1).ToString() : intValue.ToString();  private string ConvertIntAndStringToString(int intValue, string stringValue, string options)   =&gt; $&quot;{ConvertIntToString(intValue, options)} {stringValue}&quot;; <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u044d\u0442\u043e \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c. \u041a\u043e\u0434\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u2014 \u044f\u0441\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u0435. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public static class ConvertLib {   public static string IntToString(int intValue, string options) \t=&gt; options == &quot;plusOne&quot; ? (intValue + 1).ToString() : intValue.ToString();    public static string IntAndStringToString(int intValue, string stringValue, string options) \t=&gt; $&quot;{IntToString(intValue, options)} {stringValue}&quot;; } <\/code><\/pre>\n<p>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u0434\u0430? \u0425\u043e\u0440\u043e\u0448\u043e, \u0430 \u043a\u0430\u043a \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c xaml \u0441 \u044d\u0442\u0438\u043c, \u0432\u0435\u0434\u044c \u043e\u043d \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u0432? \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 <b>IValueConverter<\/b>\/<b>IMultiValueConverter<\/b> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u044c \u0441\u043c\u044b\u0441\u043b, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u043f\u043e \u043e\u0431\u0435\u0440\u0442\u043a\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440. \u041e\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439, \u0442\u0438\u043f\u0430 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">public class GenericConverter : IValueConverter, IMultiValueConverter { \tpublic GenericConverter(\/* \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432 \u0438\u043b\u0438 \u0435\u0449\u0435 \u043a\u0430\u043a-\u0442\u043e *\/) \t{ \t\t\/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \t}  \tpublic object Convert(object value, Type targetType, object parameter, CultureInfo culture) \t{ \t\t\/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043f\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \t}  \tpublic object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) \t{ \t\t\/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043f\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \t}  \tpublic object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) \t{ \t\t\/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043f\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \t}  \tpublic object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) \t{ \t\t\/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043f\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \t} } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0432\u0441\u0435 \u0432 \u0442\u0435\u043e\u0440\u0438\u0438, \u043a\u0430\u043a \u0436\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u044b, \u0438 \u043a\u0430\u043a \u0438\u0445 \u0432\u0437\u044f\u0442\u044c \u0438\u043c\u0435\u044f \u0442\u043e\u043b\u044c\u043a\u043e XAML?<\/p>\n<p>  \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438, MarkupExtension. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <b>MarkupExtension<\/b> \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <b>ProvideValue<\/b> \u0438 \u0432 XAML \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c Binding-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u0447\u043a\u0430\u0445, \u043d\u043e \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u2014 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u0423\u0441\u043b\u043e\u0432\u0438\u043c\u0441\u044f \u0447\u0442\u043e code-behind \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438 \u0432\u0438\u0434\u0430 <b>ClrNamespace.ClassName.MethodName<\/b>, \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0442\u043e\u0447\u043a\u0438 \u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e (\u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430, \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d).<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u0436\u0435 \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440? \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 (<b>MarkupExtension<\/b>) \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <b>ProvideValue<\/b> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">public class GenericConvExtension : MarkupExtension {     public override object ProvideValue(IServiceProvider serviceProvider)     { \t\t\/\/ \u041a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434     } } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u0441\u044f \u0432 \u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 XAML \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438. \u041c\u0435\u0442\u043e\u0434 \u044d\u0442\u043e\u0442 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Converter \u0443 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430 (\u0438\u043b\u0438 \u043c\u0443\u043b\u044c\u0442\u0438-\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430), \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u0442\u0438\u043f\u0430 <b>IValueConverter<\/b>\/<b>IMultiValueConverter<\/b>. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0430 \u044d\u0442\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u043a\u0430\u043a \u043f\u043e\u0434 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0431\u0438\u043d\u0434\u0438\u043d\u0433, \u0442\u0430\u043a \u0438 \u043f\u043e\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0441\u0442\u0440\u043e\u043a\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 code-behind \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 <b>MarkupExtension<\/b>-\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e:<\/p>\n<pre><code class=\"cs\">public string FunctionName { get; set; } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"xml\">&lt;TextBlock Text=&quot;{Binding IntProp, Converter={conv:GenericConvExtension FunctionName='ConvertIntToString'}, ConverterParameter=plusOne}&quot; \/&gt; <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c Extension \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f conv:GenericConvExtension \u0432 XAML-\u0435, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e conv:GenericConv. \u0414\u0430\u043b\u0435\u0435 \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cs\">public GenericConvExtension(string functionName) { \tFunctionName = functionName; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 XAML-\u0435 \u0441\u0442\u0430\u043b\u043e \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435:<\/p>\n<pre><code class=\"xml\">&lt;TextBlock Text=&quot;{Binding IntProp, Converter={conv:GenericConv ConvertIntToString}, ConverterParameter=plusOne}&quot; \/&gt; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u0432\u044b\u0447\u0435\u043a \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0435\u0437\u0434\u043e\u0440\u043e\u0432\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u2014 \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <b>ProvideValue<\/b> \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443. \u0421\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c <b>Reflection<\/b>, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c runtime-\u0442\u0438\u043f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 (\u0421 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u0430), \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443, \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u0442\u0438\u043f\u0430 \u0447\u0435\u0440\u0435\u0437 <b>Reflection<\/b> \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0438\u043f, \u0438 \u0443\u0436\u0435 \u0438\u0437 \u0442\u0438\u043f\u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0432\u0438\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <b>MethodInfo<\/b>.<\/p>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 code-behind \u043d\u0443\u0436\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f, \u043d\u043e \u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 (\u0412\u0435\u0434\u044c \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <b>Window<\/b> \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043f\u0440\u0438 \u0432\u044b\u0434\u0430\u0447\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438). \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 <b>ProvideValue<\/b>:<\/p>\n<pre><code class=\"cs\">public override object ProvideValue(IServiceProvider serviceProvider) {   object rootObject = (serviceProvider.GetService(typeof(IRootObjectProvider)) as IRootObjectProvider).RootObject;   \/\/ ... } <\/code><\/pre>\n<p>  <b>rootObject<\/b> \u044d\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0438\u0448\u0435\u0442\u0441\u044f code-behind, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043a\u043d\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <b>Window<\/b>. \u0412\u044b\u0437\u0432\u0430\u0432 \u0443 \u043d\u0435\u0433\u043e <b>GetType<\/b> \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u0438\u043c\u044f \u0437\u0430\u0434\u0430\u043d\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 <b>FunctionName<\/b>. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <b>GenericConverter<\/b>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 <b>MethodInfo<\/b> \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 <b>ProvideValue<\/b>.<\/p>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u044f \u0442\u0435\u043e\u0440\u0438\u044f, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430. \u041c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043a \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0442\u0430\u043a \u0438 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>\u041e\u0431\u0449\u0438\u0439 \u0432\u0438\u0434: '[\u041e\u0431\u0449\u0435\u0435_\u0438\u043c\u044f_\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e_\u043a\u043b\u0430\u0441\u0441\u0430] [\u0418\u043c\u044f_\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e_\u043a\u043b\u0430\u0441\u0441\u0430.]\u0418\u043c\u044f_\u043c\u0435\u0442\u043e\u0434\u0430_\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, [\u0418\u043c\u044f_\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e_\u043a\u043b\u0430\u0441\u0441\u0430.]\u0418\u043c\u044f_\u043c\u0435\u0442\u043e\u0434\u0430_\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439_\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438' \u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438-\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430\u043c\u0438: 'Converters.ConvertLib IntToString, StringToInt' = 'Converters.ConvertLib.IntToString, Converters.ConvertLib.StringToInt' \u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f code-behind: 'IntToString' \u0434\u043b\u044f one-way binding, 'IntToString, StringToInt' \u0434\u043b\u044f two-way binding \u0421\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (\u043f\u0440\u044f\u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 code-behind, \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043b\u0438\u0431\u0435): 'IntToString, Converters.ConvertLib.StringToInt' <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0441 \u043c\u0443\u043b\u044c\u0442\u0438-\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438, \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 (\u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u0434\u0435\u0442 \u0432 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0435). \u0422\u0430\u043a\u0436\u0435 <b>ConverterParameter<\/b> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, \u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043b\u0438\u0431\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 XAML \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"xml\">&lt;TextBlock Text=&quot;{Binding IntProp, Converter={conv:ConvertFunc 'ConvertIntToString'}, ConverterParameter=plusOne}&quot; \/&gt;  &lt;TextBlock&gt; \t&lt;TextBlock.Text&gt; \t\t&lt;MultiBinding \t\t\tConverter=&quot;{conv:ConvertFunc 'ConvertIntAndStringToString'}&quot; \t\t\tConverterParameter=&quot;plusOne&quot;&gt; \t\t\t&lt;Binding Path=&quot;IntProp&quot; \/&gt; \t\t\t&lt;Binding Path=&quot;StringProp&quot; \/&gt; \t\t&lt;\/MultiBinding&gt; \t&lt;\/TextBlock.Text&gt; &lt;\/TextBlock&gt; <\/code><\/pre>\n<p>  \u041c\u0438\u043d\u0443\u0441\u044b \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u0448\u0435\u043b:<\/p>\n<ol>\n<li>\u0412 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0434\u0443\u0442 \u0432\u0441\u044f\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u044f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d \u0447\u0442\u043e MethodInfo.Invoke() \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a \u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u043e, \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u0431\u044b \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043b \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0438\u043d\u0443\u0441 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 WPF\/MVVM.\n<\/li>\n<li>\u041d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f MethodInfo \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0442\u0438\u043f\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 (\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e, \u043d\u043e \u044f \u043d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a). \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043b\u0435\u0437\u0442\u044c \u0432 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u043f\u0440\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0440\u0430\u0442\u0430 \u043f\u0440\u043e\u0446. \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0434\u0438 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a.\n<\/li>\n<li>\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u0443\u043b\u044c\u0442\u0438-\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u0445 \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0434\u043b\u044f 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0443\u043b\u044c\u0442\u0438-\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u043c, \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/li>\n<\/ol>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using System; using System.Globalization; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; using System.Windows.Data; using System.Windows.Markup; using System.Xaml;  namespace Converters {   public class ConvertFuncExtension : MarkupExtension   {     public ConvertFuncExtension()     {     }      public ConvertFuncExtension(string functionsExpression)     {       FunctionsExpression = functionsExpression;     }      public string FunctionsExpression { get; set; }      public override object ProvideValue(IServiceProvider serviceProvider)     {       object rootObject = (serviceProvider.GetService(typeof(IRootObjectProvider)) as IRootObjectProvider).RootObject;       MethodInfo convertMethod = null;       MethodInfo convertBackMethod = null;        ParseFunctionsExpression(out var convertType, out var convertMethodName, out var convertBackType, out var convertBackMethodName);        if (convertMethodName != null) {         var type = convertType ?? rootObject.GetType();         var flags = convertType != null ?           BindingFlags.Public | BindingFlags.Static :           BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;          if ((convertMethod = type.GetMethod(convertMethodName, flags)) == null)           throw new ArgumentException($&quot;Specified convert method {convertMethodName} not found on type {type.FullName}&quot;);       }        if (convertBackMethodName != null) {         var type = convertBackType ?? rootObject.GetType();         var flags = convertBackType != null ?           BindingFlags.Public | BindingFlags.Static :           BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;          if ((convertBackMethod = type.GetMethod(convertBackMethodName, flags)) == null)           throw new ArgumentException($&quot;Specified convert method {convertBackMethodName} not found on type {type.FullName}&quot;);       }        return new Converter(rootObject, convertMethod, convertBackMethod);     }      void ParseFunctionsExpression(out Type convertType, out string convertMethodName, out Type convertBackType, out string convertBackMethodName)     {       if (!ParseFunctionsExpressionWithRegex(out string commonConvertTypeName, out string fullConvertMethodName, out string fullConvertBackMethodName))         throw new ArgumentException(&quot;Error parsing functions expression&quot;);        Lazy&lt;Type[]&gt; allTypes = new Lazy&lt;Type[]&gt;(GetAllTypes);        Type commonConvertType = null;       if (commonConvertTypeName != null) {         commonConvertType = FindType(allTypes.Value, commonConvertTypeName);          if (commonConvertType == null)           throw new ArgumentException($&quot;Error parsing functions expression: type {commonConvertTypeName} not found&quot;);       }        convertType = commonConvertType;       convertBackType = commonConvertType;        if (fullConvertMethodName != null)         ParseFullMethodName(allTypes, fullConvertMethodName, ref convertType, out convertMethodName);       else {         convertMethodName = null;         convertBackMethodName = null;       }        if (fullConvertBackMethodName != null)         ParseFullMethodName(allTypes, fullConvertBackMethodName, ref convertBackType, out convertBackMethodName);       else         convertBackMethodName = null;     }      bool ParseFunctionsExpressionWithRegex(out string commonConvertTypeName, out string fullConvertMethodName, out string fullConvertBackMethodName)     {       if (FunctionsExpression == null) {         commonConvertTypeName = null;         fullConvertMethodName = null;         fullConvertBackMethodName = null;         return true;       }        var match = _functionsExpressionRegex.Match(FunctionsExpression.Trim());        if (!match.Success) {         commonConvertTypeName = null;         fullConvertMethodName = null;         fullConvertBackMethodName = null;         return false;       }        commonConvertTypeName = match.Groups[1].Value;       if (commonConvertTypeName == &quot;&quot;)         commonConvertTypeName = null;        fullConvertMethodName = match.Groups[2].Value.Trim();       if (fullConvertMethodName == &quot;&quot;)         fullConvertMethodName = null;        fullConvertBackMethodName = match.Groups[3].Value.Trim();       if (fullConvertBackMethodName == &quot;&quot;)         fullConvertBackMethodName = null;        return true;     }      static void ParseFullMethodName(Lazy&lt;Type[]&gt; allTypes, string fullMethodName, ref Type type, out string methodName)     {       var delimiterPos = fullMethodName.LastIndexOf('.');        if (delimiterPos == -1) {         methodName = fullMethodName;         return;       }        methodName = fullMethodName.Substring(delimiterPos + 1, fullMethodName.Length - (delimiterPos + 1));        var typeName = fullMethodName.Substring(0, delimiterPos);       var foundType = FindType(allTypes.Value, typeName);       type = foundType ?? throw new ArgumentException($&quot;Error parsing functions expression: type {typeName} not found&quot;);     }      static Type FindType(Type[] types, string fullName)       =&gt; types.FirstOrDefault(t =&gt; t.FullName.Equals(fullName));      static Type[] GetAllTypes()       =&gt; AppDomain.CurrentDomain.GetAssemblies().SelectMany(a =&gt; a.GetTypes()).ToArray();      readonly Regex _functionsExpressionRegex = new Regex(       @&quot;^(?:([^ ,]+) )?([^,]+)(?:,([^,]+))?(?:[\\s\\S]*)$&quot;,       RegexOptions.Compiled | RegexOptions.CultureInvariant);      class Converter : IValueConverter, IMultiValueConverter     {       public Converter(object rootObject, MethodInfo convertMethod, MethodInfo convertBackMethod)       {         _rootObject = rootObject;         _convertMethod = convertMethod;         _convertBackMethod = convertBackMethod;          _convertMethodParametersCount = _convertMethod != null ? _convertMethod.GetParameters().Length : 0;         _convertBackMethodParametersCount = _convertBackMethod != null ? _convertBackMethod.GetParameters().Length : 0;       }        #region IValueConverter        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)       {         if (_convertMethod == null)           return value;          if (_convertMethodParametersCount == 1)           return _convertMethod.Invoke(_rootObject, new[] { value });         else if (_convertMethodParametersCount == 2)           return _convertMethod.Invoke(_rootObject, new[] { value, parameter });         else           throw new InvalidOperationException(&quot;Method has invalid parameters&quot;);       }        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)       {         if (_convertBackMethod == null)           return value;          if (_convertBackMethodParametersCount == 1)           return _convertBackMethod.Invoke(_rootObject, new[] { value });         else if (_convertBackMethodParametersCount == 2)           return _convertBackMethod.Invoke(_rootObject, new[] { value, parameter });         else           throw new InvalidOperationException(&quot;Method has invalid parameters&quot;);       }        #endregion        #region IMultiValueConverter        object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, CultureInfo culture)       {         if (_convertMethod == null)           throw new ArgumentException(&quot;Convert function is not defined&quot;);          if (_convertMethodParametersCount == values.Length)           return _convertMethod.Invoke(_rootObject, values);         else if (_convertMethodParametersCount == values.Length + 1)           return _convertMethod.Invoke(_rootObject, ConcatParameters(values, parameter));         else           throw new InvalidOperationException(&quot;Method has invalid parameters&quot;);       }        object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)       {         if (_convertBackMethod == null)           throw new ArgumentException(&quot;ConvertBack function is not defined&quot;);          object converted;         if (_convertBackMethodParametersCount == 1)           converted = _convertBackMethod.Invoke(_rootObject, new[] { value });         else if (_convertBackMethodParametersCount == 2)           converted = _convertBackMethod.Invoke(_rootObject, new[] { value, parameter });         else           throw new InvalidOperationException(&quot;Method has invalid parameters&quot;);          if (converted is object[] convertedAsArray)           return convertedAsArray;          \/\/ ToDo: Convert to object[] from Tuple&lt;&gt; and System.ValueTuple          return null;       }        static object[] ConcatParameters(object[] parameters, object converterParameter)       {         object[] result = new object[parameters.Length + 1];         parameters.CopyTo(result, 0);         result[parameters.Length] = converterParameter;          return result;       }        #endregion        object _rootObject;        MethodInfo _convertMethod;       MethodInfo _convertBackMethod;        int _convertMethodParametersCount;       int _convertBackMethodParametersCount;     }   } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/326646\/\"> https:\/\/habrahabr.ru\/post\/326646\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 WPF \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u0432 \u043d\u0435\u043c \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0431\u0435\u0448\u0438\u0432\u0430\u044e\u0442. \u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u2014 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b. \u0420\u0430\u0434\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0438\u0445\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0433\u0434\u0435-\u0442\u043e \u0432 \u043d\u0435\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 Ctrl+F \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f. \u0412 \u043c\u0443\u043b\u044c\u0442\u0438-\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430\u0445 \u0442\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0430\u043c \u0447\u0435\u0440\u0442 \u0437\u0430\u043f\u0443\u0442\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442 MVVM, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0447\u0443\u0434\u043e \u043d\u0430\u0443\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e. \u0427\u0442\u043e-\u0436\u0435, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0440\u0443\u0442\u0438\u043d\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u0432, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-285067","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=285067"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285067\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}