Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to not to show the defualt menu of TextBox which placed in DataGrid.

in code I can do that like that

TextBox.ContextMenu =Null;


but my TextBox which placed in DataGrid Cell is Tamplate,. xaml code like that;

<DataGridTemplateColumn  >
          <DataGridTemplateColumn.CellTemplate >
               <DataTemplate>
                   <StackPanel>
                         <TextBox>  
                                             TextWrapping="Wrap"
                                             IsReadOnly="False"
                                             ContextMenu="{x:Null}"
                         </TextBox>
                     </StackPanel>
                 </DataTemplate>
             </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>


I tried this code, but it does't work .


so, how can I set Textbox's ContextMenu to Null in Xaml?
also, I want to know how can I add my ContextMenu to TextBox in this case with code behind as well as in xaml?

could anyone tell me ? tell me relative article and info?

thanks in advance!
Posted

1 solution

Hi Alimjan,
That should work, but it looks like you have a syntax error in your xaml:

XML
<TextBox>
                TextWrapping="Wrap"
                IsReadOnly="False"
                ContextMenu="{x:Null}"
</TextBox>


it shall be:

XML
<TextBox
                TextWrapping="Wrap"
                IsReadOnly="False"
                ContextMenu="{x:Null}">
</TextBox>
 
Share this answer
 
Comments
Alimjan Yasin 28-Jul-11 4:37am    
Hi Jaime!

I tried your suggestion, but still dose not work.

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