c# - Wpf Datagrid textbox row selected -
I have a problem with a datagrid where a column is a textbox with a context menu but the problem is that then I Right clicking on the text box the row is not selected, it means that it can set the value to the wrong place. In the picture given below, it has been shown that the problem I clicked on the correct headline, but it is still the bottom line selected, which means that if I select "mixed paints" then it will want that the desired row The image below should be inserted
This is the code for the column: I found a solution to the problem: xaml code I Added: and the code behind: & lt; DataGridTemplateColumn Header = "{wpfTx: Action of Translation}" IsReadOnly = "false" width = "*" & gt; & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text box text = "{binding action, mode = twin}" textwapping = "wrap" border color = "0" borderbrush = "transparent" & gt; & Lt; TextBox.ContextMenu & gt; & Lt; ContextMenu & gt; & Lt; Menu item item source = "{binding work menu}" & gt; & Lt; MenuItem.Icon & gt; & Lt; Control: icon IconKeyName = "Config" Height = "45" width = "45" /> & Lt; /MenuItem.Icon> & Lt; MenuItem.Header & gt; & Lt; Label Content = "Standard Actions" Vertical Content Element = "Center" Font Sources = "16" FontView = "Bold" /> & Lt; /MenuItem.Header> & Lt; MenuItem.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; MenuItem command = "{binding workman command}" commandpalmter = "{binding}" & gt; & Lt; MenuItem.Header & gt; & Lt; Label content = "{binding description}" fonticizs = "16" fontweit = "bold" /> & Lt; /MenuItem.Header> & Lt; MenuItem.Icon & gt; & Lt; Control: IconKeyName = "Edited" height = "45" width = "45" /> & Lt; /MenuItem.Icon> & Lt; / MenuItem & gt; & Lt; / DataTemplate & gt; & Lt; /MenuItem.ItemTemplate> & Lt; / MenuItem & gt; & Lt; / ContextMenu & gt; & Lt; /TextBox.ContextMenu> & Lt; / Text box & gt; & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; / DataGridTemplateColumn & gt;
& lt; DataGride Mouse Write ButtonUp = "UIElement_OnMouseRightButtonUp" name = "DataGrid1" & gt; & Lt; / DataGrid & gt;
Private Zero UIElement_OnMouseRightButtonUp (Object Sender, MouseButtonEventArgs e) {var dep = (DependencyObject) e.OriginalSource; While ((dep! = Null) & amp; (deputy is DataGridCell)) {dep = VisualTreeHelper.GetParent (dep); } If (DP == blank) return; If (DPE is DataGridsel) {var cell = Datagidcel as; Cell.Focus (); While ((DP! = Faucet) & amp; (DPE DatagridRo)) {DP = VisualTrifer.GatePant (DP); } Var row = deprecated as datagram; DataGrid1 Selected Ietem = Row.DataContact; }}
Comments
Post a Comment