Click here to Skip to main content
15,038,451 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone.
I wrote next code of XAML:
XML
<ToggleButton x:Name="toggleButton" Content="Toggle"/>

<Button Content="Button" Height="62" Name="button1" Width="113" IsEnabled="{Binding IsChecked, ElementName=toggleButton}"/>

<DataGrid AutoGenerateColumns="False" Height="71" Name="dataGrid1" Width="175">
    <DataGrid.ContextMenu>
        <ContextMenu>
            <MenuItem Header="menuItem1" IsEnabled="{Binding IsChecked, ElementName=toggleButton}" Name="menuItem1" />
        </ContextMenu>
    </DataGrid.ContextMenu>
    <DataGrid.Columns>
        <DataGridTextColumn Header="Column1" />
        <DataGridTextColumn Header="Column2" />
        <DataGridTextColumn Header="Column3" />
    </DataGrid.Columns>

Binding for button1 work fine, but databinding for menuItem1 doesn't work. Can you tell me where I am wrong and how can I use databinding for MenuItem?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900