Can we add custom markups?
Is it possible to register a custom markup tag, like below
The intention is to do automatic bindings by scanning the XAML and add data context to all of these CustomMarkUps
this control do not need to have its own display, can be a empty container.
Code: Select all
<CustomMarkUp x:Name="AAAA" content="I am a custom context">
<Button x:Name="Button" Width="100" Content="Click me" Command="{Binding AutoCommandCall}"/>
</CustomMarkUp >
this control do not need to have its own display, can be a empty container.
-
sfernandez
Site Admin
- Posts: 3008
- Joined:
Re: Can we add custom markups?
Of course, you can extend Decorator (which already provides a Child property) and use it in the xaml with the appropriate namespace:
Anyways, you don't need any of this to assign a custom data context to the Button, you can just expose it the current view model:
This will resolve the AutoCommandCall against the viewmodel exposed in CustomDataContext property. Could that work for you?
Code: Select all
using Noesis;
namespace MyNamespace
{
public class CustomMarkup : Decorator { }
}
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace">
<local:CustomMarkup>
<Button x:Name="Button" Width="100" Content="Click me" Command="{Binding AutoCommandCall}"/>
</local:CustomMarkup>
</Grid>
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button x:Name="Button" Width="100" Content="Click me" DataContenxt="{Binding CustomDataContext}" Command="{Binding AutoCommandCall}"/>
</Grid>
Who is online
Users browsing this forum: Bing [Bot] and 6 guests