C# : WPF Mouse Over - c#

I need to create a WPF application , which contains two windows.. the window1 contains a button. i need to show the second window when the cursor is over the button in first window
[ Like tooltip ] . if the mouse leaves, the second window should close..
I'm new to WPF. can any one help me with a sample code

If it is possible to do without your second window something like this is usually done in a tooltip, which has exactly that behaviour. (e.g. http://www.c-sharpcorner.com/UploadFile/mahesh/FancyWPFTooltip07132008214937PM/FancyWPFTooltip.aspx)

Check out System.Windows.Controls.Primitives.Popup. It is maybe what you are seeking.

Related

WPF Window in Window (c#)

I have a WPF Window in which I want to "open" other windows/interfaces. So that when I click on one of the labels, a "Popup" opens where I can do stuff (Input via a Textbox, images, buttons etc.). I already found this but it seems that this is not really what i am looking for. Images below. Would be nice if someone could point me in the right direction.
What I have
What I want to do/how it should look
This project shows how you can display dialog like content in a DropDownButton control:
https://github.com/Dirkster99/fsc/blob/master/source/Apps/FolderBrowserDemo/MainWindow.xaml
So, I think you probably do want a DropDownButton control like this:
https://github.com/Dirkster99/DropDownButtonLib
with a custom view as shown in your screenshot. This solution is quit advanced though but I hope it helps.

Button with no hWnd

Good evening folks,
I'm building a simple application (A) that sends Strings to a textbox of another application (B). I was able to this step, but afterwards I'd like to automatically press a button placed just under the textbox. The problem is that I can't get the Handle of the Button; using "Window Detective"(similiar to Spy++), I see only the textboxes (called "TEdit", see the attachments) and no Buttons!. I'd like to add also that there's no only a Button but 3!! So, how could I press a specific Button? Is there another chance to get the Handle?
Program "target"
Window Detective screenshot
Based on the class name TEdit that's a VCL application probably coded in Delphi. The buttons are likely TSpeedButton and non-windowed. You won't be able to send them messages and they are not automatable.
Faced with this your best hope of success is to fake input. Fake the mouse click at the appropriate location on the form. It's not pretty but there's little option.

Disabling Dialog Flashing C#

I have a populated ListView dialog. If a user clicks on an option in the ListView, a new dialog is shown above the ListView.
My problems is that when I click off of the new top-most dialog (onto the ListView behind it), the new dialog's borders flash/blink several times. The icon on the taskbar also flashes. I wish to disable the flashing, but cannot find a property to change.
To show my dialog, I use the following code:
if (detail == null)
detail = new Details(opt, val, user, desc, m_l);
else
detail = null;
detail.ShowDialog();
This is intended behavior, it's because the new dialog is modal. It's drawing attention to the fact that something needs to be done.
If you need to make a non-modal form, instead of using ShowDialog(), simply use Show().
Sounds like to me you are creating modal windows each time. And you cannot resume the previous dialogs until you dismiss your new top-most window.
Take a look at this wikipedia article for information about modal dialogs.
I would advise you look at how you are creating/showing your windows.
In WPF you show windows via Show() or ShowDialog(), however, I do not know which type of ListView you are using
EDIT:
Per your comment, you want modal dialogs. The only ways I can think of even trying to remove the flashing is going into WINAPI. This doesn't seem like a job for .NET.
I want to suggest a few things:
Take a look at options for showing each window. See this MSDN page
Take a look at the options for styling each window. See this MSDN page
Reconsider your design. I know this may take a lot of work, but having so many layers of windows is kind of unappealing to most users. Ultimately, I believe this option will make your application the best.
Thank you all for your answers and guidance. I have found the best way to handle my problem.
I was using an event ItemActivated. This event was called when an a highlighted item on the ListView was clicked. This became a problem when the user would double click on an already selected item. This would cause the new dialog to show, but also flash several times.
By using the DoubleClick event instead, a single click on a selected object does nothing. A double click on either a selected or non-selected item opens the dialog without the flashes. The flashes still appear if you try to click off of the dialog box, but are not as much of an issue.

Creating popup without possibility to tab to a background element

I am trying to create a popup but when it is open it is still possible to use the tab key to switch the focus to an element in the background (e.g. to a button and use space to press is). The only way I found until now is to check on every lostFocus event (which also fires for every element contained in the Border element) and check if the focus is now in a element inside the Border. If not I manually set the focus.
Is there a nicer way to keep the focus within the Border (or a Grid,...)
I'm working on a Windows 8 App.
Do you mean that using a Modal Dialog with Form.ShowDialog(Owner) still allows you to focus the parent components with Tab?
Can you give a sample of your code call?
Form2 form = new Form2(); //Make an instantiation of your Form
form.ShowDialog(); //ShowDialog()!!! NOT form.Show()!!! Or anything else :/
A few ideas:
Set Enabled to False on the background visual tree, though that might change the way things look if you still want to show them partly
Set IsHitTestVisible to False to disable pointer input
Use RenderTargetBitmap.Render() if targeting Windows 8.1 to render the content of the background to an image and simply replace all that visual tree with an image of it

Multi-Page WPF Application

I am new to desktop application development and have a pretty basic question. I have a WPF form named MainWindow, how should I go about having multiple pages on this, such as "User Management", "Manage Content" etc..
I think I have the following options:
Use multiple forms
Tabs
Group Box?
Any clarification would be great!
Well in my most recent application I started by using a TabControl, that's a safe and rather easy way to go.
Recently switched the tabcontrol with a StackPanel with a series of Expanders inside. I styled the expanders to have them display the header vertically and expand horizontally... somewhat similar to the first xbox dashboard. And it looks and works great! =)
Another alternative would be to use a Page instead of a window... Then you would just have to Navigate to each different page.
EDIT:
Here's an example of a multi-page application... might be close to what you need.
The solution I went with that suited what I was looking for was using WPF Pages but thanks for your answers.
There are many ways to do that, such as creating UserControl and show them in the run time.But using TabControl is fast and safe.
Just Use TabControl and place your pages in tab items .Then hide the header of TabControl by setting the value Visibility="Collapsed" to each TabItem.
The result is as below:
As you see the headers are hide and you can switch to each page you want.
Create
usercontrol(wpf): UserManagement
usercontrol2(wpf) : ManageContent
place control "ContentControl" in the main window
Run the code on click of button:
//Displays usercontrol1
contentControl.content = new UserManagement();
//Displays usercontrol2
contentControl.content = new ManageContent();
Hope this helps you.
I'd like to give you an example of something I have in one of my applications.
The app has two windows: the main window and another one (also derived from Window and equipped with the appropriate buttons and event handlers) that is used as a start dialog. The start dialog is called in the constructor of the main window like this:
public partial class MainWindow : Window
{
startdlg m_dlg;
// ...
public MainWindow()
{
m_dlg = new startdlg();
if ((bool)m_dlg.ShowDialog())
{
// ...
}
else
{
Close();
}
// ...

Categories