markup-extensions

MarkupExtension.ProvideValue — Is the IServiceProvider actually used?

一世执手 提交于 2019-12-05 00:13:11
问题 I was going through some old code of mine and came across a hybrid IValueConverter / MarkupExtension class. It got me wondering if the IServiceProvider in the ProvideValue method was actually useful, and how it would be useful? I see that IServiceProvider only has one method: GetService , which must be cast to the proper service type. I also looked at the MarkupExtension.ProvideValue MSDN page and it lists different types of services. I guess, I'm just wondering if any of those services are

VS2010 Custom MarkupExtension

◇◆丶佛笑我妖孽 提交于 2019-12-04 15:18:48
问题 We have just switched to vs2010 from vs2008, and our projects compile and run well without any problem. However, the xaml designer has some errors. Here is one of the errors hope someone can provide a solution. We have a custom MarkupExtension, and we use it in xaml to get certain resources. Something like this: <Button Style="{l:GetResource Key=MyButtonStyle}" /> I know we can use StaticResource or DynamicResource. However we have our reasons to use the custom markupextension. The error

Can XAML 2009-related markup extensions be used in WPF?

隐身守侯 提交于 2019-12-03 08:40:29
问题 I'm talking about extensions such as x:Reference and x:FactoryMethod , collectively appearing here. I'm reading a lot of contradictory information online, including on MSDN, Stackoverflow, and from other sources. I'll talk about x:Reference as an example, but I'm actually referring to the other markup extensions as well. The primary causes of confusion are the following excerpts from MSDN: XAML 2009 Language Support in WPF In WPF, you can use XAML 2009 features, but only for XAML that is not

How to make Resharper resolve path for CustomBinding MarkupExtension

寵の児 提交于 2019-12-03 04:09:05
I want to create some extended Binding-Markup-Extension, which behaves just like a normal WPF-Binding but does some things more (use different defaults, maybe add some behavior, etc.). Code looks like this: public class CustomBindingExtension : Binding { .. some extra properties and maybe overrides ... } It all works fine including XAML-intellisense, except I just can't make Resharper resolve my Binding-Path correctly. I.e.: using this code I can [Strg]+Click on 'CurrentText' and Resharper lets vs2010 navigate to the code defining the CurrentText-Property. <UserControl x:Name="uc" ...>

Can XAML 2009-related markup extensions be used in WPF?

纵饮孤独 提交于 2019-12-02 22:28:40
I'm talking about extensions such as x:Reference and x:FactoryMethod , collectively appearing here . I'm reading a lot of contradictory information online, including on MSDN, Stackoverflow, and from other sources. I'll talk about x:Reference as an example, but I'm actually referring to the other markup extensions as well. The primary causes of confusion are the following excerpts from MSDN: XAML 2009 Language Support in WPF In WPF, you can use XAML 2009 features, but only for XAML that is not WPF markup-compiled. Markup-compiled XAML and the BAML form of XAML do not currently support the XAML

How does one use the UWP MarkupExtension class?

橙三吉。 提交于 2019-12-02 00:45:31
问题 Fall Creators update SDK added a Markup Extension class, great. https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.markup.markupextension So I create one and override and "ProvideValue" method. public class MDL2 : MarkupExtension { ... public string Target { get; set; } protected override object ProvideValue() { ... } } I attempt to use it as such in a style: <Setter Property="IconGlyph" Value="{u:MDL2 Target='Delete'}" /> Now, this will properly call the constructor for my MDL2

How does one use the UWP MarkupExtension class?

无人久伴 提交于 2019-12-01 21:36:54
Fall Creators update SDK added a Markup Extension class, great. https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.markup.markupextension So I create one and override and "ProvideValue" method. public class MDL2 : MarkupExtension { ... public string Target { get; set; } protected override object ProvideValue() { ... } } I attempt to use it as such in a style: <Setter Property="IconGlyph" Value="{u:MDL2 Target='Delete'}" /> Now, this will properly call the constructor for my MDL2 extension, and set the Target property to a string value of "Delete". So far so good. Except, the ProvideValue

Set custom MarkupExtension from code

懵懂的女人 提交于 2019-12-01 04:37:02
How do you set a custom MarkupExtension from code? You can easily set if from Xaml. The same goes for Binding and DynamicResource . <TextBox FontSize="{Binding MyFontSize}" Style="{DynamicResource MyStyle}" Text="{markup:CustomMarkup}"/> Setting the same values through code behind requires a little different approach Binding: Use textBox.SetBinding or BindingOperations.SetBinding Binding binding = new Binding("MyFontSize"); BindingOperations.SetBinding(textBox, TextBox.FontSizeProperty, binding); DynamicResource: Use SetResourceReference textBox.SetResourceReference(TextBox.StyleProperty,

String format with a markup extension

隐身守侯 提交于 2019-11-30 17:47:53
I am trying to make string.Format available as a handy function in WPF, so that the various text parts can be combined in pure XAML, without boilerplate in code-behind. The main problem is support of the cases where the arguments to the function are coming from other, nested markup extensions (such as Binding ). Actually, there is a feature which is quite close to what I need: MultiBinding . Unfortunately it can accept only bindings , but not other dynamic type of content, like DynamicResource s. If all my data sources were bindings, I could use markup like this: <TextBlock> <TextBlock.Text>

String format with a markup extension

╄→гoц情女王★ 提交于 2019-11-30 16:51:43
问题 I am trying to make string.Format available as a handy function in WPF, so that the various text parts can be combined in pure XAML, without boilerplate in code-behind. The main problem is support of the cases where the arguments to the function are coming from other, nested markup extensions (such as Binding ). Actually, there is a feature which is quite close to what I need: MultiBinding . Unfortunately it can accept only bindings , but not other dynamic type of content, like