Rafael
Rafael

Reputation: 85

Receive a <Menu> by TemplateBinding wpf

I have the code below that is the template :

<Style TargetType="controls:ModernVerticalMenu" >
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="controls:ModernVerticalMenu">
                <Grid>
                        <!--I would like to set here the Menu that i received from the property {TemplateBinding Menu}-->
                        <Menu>
                        </Menu>     

                </Grid>

            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

And I am trying to use like this:

<controls:ModernVerticalMenu>
    <controls:ModernVerticalMenul.Menu>
         <!--Menu-->
    </controls:ModernVerticalMenu.Menu>
</controls:ModernVerticalMenu>

I need know what I have to put in the first part to receive the Menu that I use in the second code.

Upvotes: 0

Views: 54

Answers (1)

Sjeijoet
Sjeijoet

Reputation: 741

You could add a simple ContentPresenter:

<ControlTemplate TargetType="controls:ModernVerticalMenu">
    <Grid>
        <ContentPresenter Content="{TemplateBinding Menu}"/>
    </Grid>
</ControlTemplate>

Upvotes: 1

Related Questions