I am using wpfToolkit:DataGrid in my application.
If I tried to doubleclick on the corner of selectedrow ,It gives null value.
But If I click in the middle of the selectedrow I am able to get the cell value.
Kindly help me to get the selectedrow cell value irrespective of by dobule clicking any place of the selectedrow.
Try giving your cell a background color. Quite often the default background color of WPF controls is transparent, so they do not register things like Click events. For example, a TextBlock with a DoubleClick event to copy the text will only work if you double-click on the text itself and not any of the whitespace around it unless you set a background color.
This will also show you if the area you are clicking on is considered part of the Cell or if it is just Margin/Padding
Related
I have a textbox and some labels inside the data template of bounded listbox.
When I click on any label the whole item is highlighted in blue, but when I click directly on a different textbox the selection does not change.
Is there a way to make the selection of the listbox change even when a textbox is clicked?
thanks
This is what I've exactly asked few days ago, see post: "WPF: Trigger SelectedIndex changed whilst clicking on any control within a ListBoxItem area"
basically there are few solutions, using code behind and XAML, but I've not verified latter approach yet
The reason is because the TextBox handles the click event in order to receive focus. There are a number of ways to handle this, including but not limited to:
stop the TextBox handling mouse events (which prevents the user from focussing it using the mouse)
use an eventhandler when the TextBox gains focus (or PreviewClick or similar), to select the parent ListItem
I am trying to bring the focus on the clicked item of the surface listbox. For WPF I had a similar post and it worked after setting the trigger property of .
The full xaml code is available at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5d486826-9a72-4769-bd09-ff6977e16c30/#cd2cd9af-abbf-40ca-9e30-4684ee2a2eb2
I tried doing the same in the xaml code for a surface button which is put as item in surface listbox, nothing happens. Basically, my listbox contains surface buttons and when any button is clicked, it scales up i.e. the size of it increases. The only issue is that next item overlaps the scaled item because of the z-order issue. For the normal WPF listbox and button control above code did the trick but its not happening for surface application.
Would appreciate any help/directions in this issue.
Got it working.. Had posted on MSDN and it finally worked by setting the zIndex of the surfaceListbox instead of the content of the item which was a surfacebutton.
http://social.msdn.microsoft.com/Forums/en-US/surfaceappdevelopment/thread/970877bd-2960-4f0e-a203-1d357bbd55ce/#4a08e54b-5055-4a66-ad75-762ee88ef303
My WPF combobox is populated with a different set of strings each click of a button. There are other controls on the window as well. The combobox is the 'first' (top) in the window, but the text doesn't get highlighted. When the user tabs through the controls, the text DOES get highlighted, but when it's the first on the window, it doesn't.
Maybe i need to force a highlight on the individual textbox control 'within' the combobox itself, but how would i do this? I couldnt seem to find the internal 'structure' of this control anywhere. Could anyone help here?
Jack
to get the TextBox of Combobox you can use
TextBox TxtBox = (TextBox)myCombo.Template.FindName("PART_EditableTextBox", myCombo);
I'm not sure it's the best solution, but you can use FrameworkElement.FindName to access the child control -- it's guaranteed to be present in a combobox, because it's a key constituent part of the control.
That stated, is it not better to try and call .Focus() on the control? That is likely why when you tab, the highlight is provided.
Another option is to derive from ComboBox, and expose the child text box as a property allowing you to set it's selection, or add a method directly to the combobox to set it for you.
I have a text box that has spell check enabled. It is inside a popup. This enables me to edit multi line text in a datagrid, when the text is being edited the text box it is in grows over the top of the grid instead of resizing the height of the row.
The problem is that when the red squiggly lines appear to indicate a spelling mistake i cant right click on them, because when i do the popup closes.
I have tried Popup.StaysOpen but to no avail. any ideas?
Have you tried this outside the context of the DataGrid? I have a hunch that it is most likely the DataGrid detecting that focus has been lost and is automatically applying your edits, changing the template for the cell and thus closing your Popup.
The new data validation in silverlight 3 has a red textbox that flies out to the right. This is a problem for me because I have have a textbox to the right that is getting covered by the popup.
How can I make this popup move somewhere else?
Retemplate the textbox. The tooltip is found in there. You can modify it using the placement property or margins to appear elsewhere.