Adding items to below gridview when dropped on top gridview - silverlight

On my main page, I have a button and telerik mainRadGridView. When I click my button, I get a popup which is divided it into two regions left and right.
On left, I have a RadTreeView and on right, I have a popupRadGridView.
Initially when my popup is open, the popupRadGridView is disabled. When I drop from left to right for first time in my popup nothing is added to popupRadGridView since it is disable which is correct.
But when I drop for second time on to my disabled popupRadGridView inside my opened popup, there is an element added to my mainRadGridView on my main page which is wrong.
I cannot understand how to stop adding onto my main page. Any help is greatly appreciated.

check for the e.Options.ParticipatingVisualRoots in Drop Event of GridView - should provide you the no of active opened child windows participating in the operation.
For additional information follow this link
Telerik Silverlight

I solved my issue as below
In my mainpage codebehind. I did like below
void mainRadGridView_OnDropInfo(object sender, DragDropEventArgs e)
{
if(e.Options.ParticipatingVisualRoots.Count > 0)
{
return;
}
else
{
do stuff;
}
}

Related

Prevent drop-down menu to close

I have a big problem. I want to prevent an opened drop-down menu to close when hovering another menu item. How can I achieve this? Thanks.
Regards
Marius
You should have a look at the event that's called when you are hovering another item, probably LostFocusor LostMouseCapture, look at the function called aith this event (OnLostFocus or OnLostMouseCapture) and override this method like this :
public override void OnLostFocus()
{
base.OnLostFocus();
Popup popup = Template.FindName("PART_Popup", this) as Popup;
popup.IsOpen = true;
}
This way, the event won't close the drop down menu. (The example above is for a combobox)
I'm not sure about the right event to override. It depends on your problem. You can find the list of event here if these are not the right ones. But I think that's the way you should do it.

WPF Tab_selectionChanged

I have this strange issue I am facing currently.
I have created an WPF application based on WPF page navigation. I have few button and depending on the button click the the user is navigated to respective WPF page.
In these WPF pages I have Tab controls and have used selectionchanged event handler to perform some task.
Now to the issue,
When I try to go a particular page, the selectionchanged event is also executed even before the page is loaded completely, I have tried to use the windows.loaded (based on the answer provided to my previous question - here) - I have no luck.
[I am using WPF Navigation framework]
Somehow the selectionchanged event is executing twice.
How do I stop this from happening?
I think you should check SelectionChange.AddedItems and SelectionChange.RemovedItems to find the difference between these to firings. I guess that when you select a page, SelectionChange.RemovedItems==0 while when you click on a tabItem to select it, SelectionChange.RemovedItems==1. if so just write:
if (SelectionChange.RemovedItems==0)
return;
Edit1: Please see the first comment.
Edit 2
void tablcontrol_SelectionChange(object sender, SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count == 0)
{
// I guess this is the event that happens when a page is selected
// in this case just a TabItem is added to the selection
// and nothing is removed, so do nothing
return;
}
// if you are here, it means that this is another selection changed event
// so Perform those tasks that you mentioned in your question
}

updating UI in windows phone 7

In method that is working in the background, i have two important lines :
createPopup();
MessageBox.Show(sth);
more lines
more lines
createPopup() just creates a popup, adds a grid as a child and shows popup.
My question is, why first shows up messageBox, then shows up Popup, which appears after all lines in this method done ? How could I make this popup to show before all lines in this method will be done ?
All the UI changes are normally queued up and will be shown at once on the screen.
And this does not include MessageBox. So it shows up immediately and prevents the execution, until user clicks on Ok. Hence eventhough your popUP is first executed, it will be shown in the UI only after the MessageBox.
For your problem, Try placing your MessageBox.Show(something) in a separate thread.
createPopup();
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("some message");
});
more lines
more lines
Give it a try. I am not sure whether it solves your problem or not as I dnt know the code in createPopUp() method.
Creating the pop-up, does not actually draw it on the screen until the Layout event. If you want to ensure that the pop-up has been drawn before you display the pop-up, attach an event handler to the pop-up's LayoutUpdated event and display the message box from within that event handler. Be sure to detach the event handler as well or you will see multiple message boxes.
public InitPage()
{
Popup popup = new Popup();
popup.LayoutUpdated += popup_LayoutUpdated;
LayoutRoot.Controls.Add(popup);
}
void popup_LayoutUpdated(object sender, object e)
{
popup_LayoutUpdated -= popup_LayoutUpdated;
MessageBox.Show("hello");
}

ContextMenuStrip loses the focus from an item in the tree view if it is right clicked

I have a contextmenuStrip associated with a tree view.
Now for instance, i have four nodes in the tree structure and Node 4 is selected.
Behavior:
ContextMenuStrip - When u right click on the Node 2 , that node is selected and as soon as the context menu strip opens up, the focus goes back to Node 4.
With old component 'Context Menu' this functionality works fine i.e. Node 2 has the focus till the time context menu is open.
I would like to have Node 2 selected as long as context menu is open. And selection/focus shall go back to Node 4 when context menu is closed.
Request please advice.
Thanks and Best Regards
Sumit
Yes, the TreeView control is pretty flaky when the focus is changed while one of its events runs. Which is one reason it distinguishes the BeforeXxxx and AfterXxxx events. Unfortunately, the context menu strip is shown too soon. The solution is to display the context menu yourself by implementing the NodeMouseClick event. Like this:
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) {
if (e.Button == MouseButtons.Right) {
treeView1.SelectedNode = e.Node;
contextMenuStrip1.Show(treeView1, e.Location);
}
}
I'll leave restoring the focus afterwards up to you. It doesn't make much sense to implement it.

UI Design Concepts in WinForms

In one certain case I want to disable the tabpannel so that the controlls in the tab panel are disabled.
I want to disable the tab pannel but still I want ennable the controls in tab pannel.the need is User cannot switch over to the annother tabpannel in a certain senerio.
How can I do this requirement?.
by
dinesh
Use something besides a tab panel.
It is not standard behavior for a tab panel to have one tab "stuck" so that the user cannot move to the other tabs. You're going to throw users off if you do this.
What you are after sounds like a modal dialog. It sounds like you don't want the users to move away from a certain screen until they're doing entering some data or some such. The modal dialog is built for this purpose.
There is no direct way to disable Tab Page, only you can remove it. But in your case, you can't remove the Tab, So I think you need to put some code in the Tab_SelectionIndex change event. And when ever the Tab index comes, set it back to another one.
Try this code
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 1)
{
tabControl1.SelectedIndex = -1;
}
}
In addition to anuraj's answer, set the colour of the tab text to the disabled text colour state, so it is a visual cue it is "disabled".

Resources