Are there any markup that allows me to set its DataContext but doesn't do anything as graphic?

51 Views Asked by At

I'm working on a project where things aren't build "very well". Because I want create something like a "partial model" for a part of the window where I will put my controls, I would like to know if there is a markup that will allow me to specify its DataContext but doesn't change the window graphic in any way (adding buttons and things like that).

If not, how can I create one by myself (I think by intheriting MarkupExtension), and more important: can be done?

Thanks for any answer

EDIT 1:

An example of my idea is this one:

<SomeControl>
    <TextBlock />
    <ThisMarkupDoNothing DataContext="{Binding my:Model}">
        <ComboBox ItemsSource="{Binding MyModelProperty}" />
    </ThisMarkupDoNothing>
</SomeControl>

Maybe this can help understand what I mean.

1

There are 1 best solutions below

1
On BEST ANSWER

You could use ContentControl for that:

<SomeControl>
    <TextBlock />
    <ContentControl DataContext="{Binding my:Model}">
        <ComboBox ItemsSource="{Binding MyModelProperty}" />
    </ContentControl>
</SomeControl>

Other options include UserControl and Border without actually setting the border properties.