Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Please can you help me how can i create popup panel with informations for mouseover. I using C# offline application.
I don't know how can i do this on mouseover with application. For website it is javascript but for C# ... i don't know.
I know how to use mouseover for it, but i don't know how to create popup window with informations for mouseover. It's exactly my problem. Please can you help me?
You could start by testing the following:
You can use MouseEnter to show a window in a popup style.
private void panel1_MouseEnter(object sender, System.EventArgs e)
{
MyForm frm = new MyForm();
frm.ShowDialog();
}
When you require behavior like jquery UI Tooltip you can use UserControl
private Control popup;
private void panel1_MouseEnter(object sender, System.EventArgs e)
{
MyUserControl mcu = new MyUserControl ();
this.popup =mcu; //save references to new control
this.Controls.Add(this.popup);
this.popup.Location.X = ((Control)sender).Location.X+ offsetX;
this.popup.Location.Y = ((Control)sender).Location.Y+ offsetY;
}
private void panel1_MouseLeave(object sender, System.EventArgs e)
{
this.Controls.Remove(this.popup);
}
This sounds suspiciously like a ToolTip.
So I recommend that you use the ToolTipService for this (in your xaml):
<object>
<ToolTipService.ToolTip>
<objectThatFillsTheToolTip .../>
</ToolTipService.ToolTip>
</object>
This sample is from the msdn docu page.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to create a WPF App in VS which should have various features (no serperate applications!).
The MainWindow should containt several Icon's (like App Icon's on Smartphone) which represents each of my features. So the MainWindow should be as an overview of my features. How do I need to realize it?
Which toolbar object represents an Icon? (Button?)
If I click on the Icon (Button?) the new feature should be showed as fullscreen (like on a Smartphone by clicking/starting an App). Which feature of WPF should I use to show the Page/Window of the Feature? If I close the feature the MainWindow should be showed again. I would be glad about a code example
Thanks
This question is likely too broad to get you the answers you are looking for, but a good place to start is with the Window class.
Once you create your buttons, you can spawn a new Window for your distinct feature. The Window.ShowDialog method will allow the new feature to remain active until it is closed. Setting the Window.Owner property will allow the new feature to return control to MainWindow.
I'd recommend trying some of these features out then coming back with specific questions you might have.
MainWindow.xaml
<Window x:class="MainWindow">
<!-- ... -->
<Button Click="Feature1_Click" Content="Open Feature 1"/>
<Button Click="Feature2_Click" Content="Open Feature 2"/>
<!-- ... -->
</Window>
MainWindow.xaml.cs
public class MainWindow : Window
{
//...
private void Feature1_Click(object sender, RoutedEventArgs e)
{
new Feature1Window
{
Owner = this
}.ShowDialog();
}
private void Feature2_Click(object sender, RoutedEventArgs e)
{
new Feature2Window
{
Owner = this
}.ShowDialog();
}
// ...
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
When creating a winforms application I added a pannel as a header so I could make the application borderless, I was going to add some buttons when I realised no events were getting registered by the program. Have I flicked a wrong switch somewhere?
I have already tried clicking the main form and changing the AutoValidation as well as checking that the form, as well as the panel, were both enabled.
public App()
{
InitializeComponent();
}
private void TopBar_MouseHover(object sender, EventArgs e)
{
Application.Exit();
}
private void ExitButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
Expect result is that it should just close the application when I hover over the topbar or when I click the ExitButton.
I fixed this by going through the properties of the Forms/Buttons and resetting them as it turns out I had one item disabled.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
There is a comboBox and a button on a win form. How can I fire the comboBox selectedIndexChanged by clicking on the button.
You should rethink your code design a little. It seems you want to raise the event to trigger some action indirectly. Why not try it like this:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// do the things that should happen only if a real change happend
// ...
// then do the special thing you want
DoTheOtherStuff();
}
private void button1_Clicked(object sender, EventArgs e)
{
// do the things to happen when the button is clicked
// ...
// then do the special thing you want
DoTheOtherStuff();
}
private void DoTheOtherStuff()
{
// the special thing you want
}
EDIT: If your legacy code is so awkward as your comment suggests, you can still use this awkward way:
private void button1_Clicked(object sender, EventArgs e)
{
comboBox1_SelectedIndexChanged(comboBox1, EventArgs.Empty);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am doing a school project and i canĀ“t figure out how to "hide" some text blocks when the toggle switch is on and the opposite? Developing a windows 8 app. Thanks and btw. How do you make a collection from multiple text blocks(XAML)?
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
}
Assuming your control structure is fairly flat, you can get by using the Tag property on the TextBox. In your XAML, put some distinct value in the Tag field for each TextBox you want to make toggle-able, like the word 'CanToggle'. Then you can do something like
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
foreach (Control currentControl in this.Children)
{
if (currentControl.Tag == "CanToggle")
currentControl.Visible = !currentControl.Visible;
}
}
If your control collection is not flat, then you'll have to figure out how to dig recursively through the collection of controls to locate all the TextBox that you want to toggle. This answer may help.
Visual Studio Main Menu - Edit - Outlining - Toggle All Outlining: Ctrl+M, Ctrl+L
Personally, I use Ctrl+M to "collapse to defininitions" more than anything else though.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Having hard time dealing with this because every time I navigate to another form my project lags or is unresponsive for a few seconds before it shows the content of the window.
How can I close all the child windows with a method?
I have tried this.Close() but that didn't work.
You may use Application Class as a place of storing a links to the child windows. It creates a singleton Current which is accesable from any place
public partial class App : Application
{
private List<Window> childWindows = new List<Window>();
public List<Window> ChildWindows{get{return childWindows;}}
}
To register new ChildWindow add this into Initialized event handler
private void ChildWindow_Initialized(object sender, EventArgs e)
{
((App)Aplication.Current).Windows.Add(this);
}
on ChildWindow Closing you have to remove link from collection
private void ChildWindow_Closed(object sender, EventArgs e)
{
((App)Aplication.Current).Windows.Remove(this) // here
}
if needs you may replace List with Dictionary to have a possibility of searching by key