Visual Studio 2022 .net 6 or 7 winform designer cannot generate event handler code automatically after renaming MainForm - winforms

I have a question while using Visual studio 2002 for winform .net 6 or 7
Visual Studio 2022 .net 6 or 7 winform designer cannot generate event handler code automatically after renaming "Form" to "MainForm".
I tried to double click winform designer mainform for generate "MainForm_Load" event handler code
But, The code is not generated and "MainForm.Designer.cs" is no code for that.
I cannot make sense for this situation.
But, In .net framework winform, this code is generated correctly.
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
}
}
Please let me know that if it's bug or has a solution for this problem.
Thank you in advance.
Regards.

Related

XAML Islands ProgressRing White Background

I'm porting a WPF app to WPF .NET Core 3.0. I'm trying to use UWP controls using XAML Islands via WindowsXamlHost from the Community Toolkit. The WindowsXamlHost control itself has a white background and I don't know how to get rid of it. Here's an example of a ProgressRing:
<xamlHost:WindowsXamlHost x:Name="MyRing" InitialTypeName="Windows.UI.Xaml.Controls.ProgressRing"/>
private void MyRing_ChildChanged(object sender, EventArgs e)
{
if (MyRing.Child is ProgressRing progressRing)
{
progressRing.IsActive = true;
var brush = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
progressRing.Background = brush;
}
}
Giving the ProgressRing object a new background color works but doesn't help if I'm after transparency. I'm using .NET Core 3 preview 7.
I'm not sure whether it is possible. I have a similar issue which I reported here: https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/160#issuecomment-522288462. Hopefully, Microsoft employees will answer there.

WinForm progressbar not working when I open that form in Wpf application?

I created a Windows form project in Visual studio and used a progress bar with style as marquee and I created another wpf project and added windows project reference to the newly created wpf project and call the form in a button click event as
private void Button_Click(object sender, RoutedEventArgs e)
{
Form1 form = new Form1();
form.Show();
}
But the progress bar inside the form is not working.
I fixed the above issue by adding the following lines
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

Why is DragDrop not working under VS2010?

I have a winforms app that uses a UserControl. The user control's job is to collect a file that the user drops on it from Windows Explorer, Open the file, determine the type and handle it accordingly.
This control worked PERFECTLY under Visual Studio 2008 Pro. I upgraded to VS 2010 Pro, and now, it doesn't work. Is there a flag or a property that has changed that I should be aware of??
I made a quick demo to test. This demo works perfectly under 2008, but doesn't work at all under 2010.
The setup: Create a new winform project. Add a user control. Set the following code in the user control's code section. (compile to get the user control to appear in the toolbox) Add the user control to the form. Run the program, and drag ANY file from windows onto the form. If it works, the user control area should change colors.
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
this.AllowDrop = true;
this.DragDrop += new DragEventHandler(UserControl1_DragDrop);
this.DragEnter += new DragEventHandler(UserControl1_DragEnter);
this.DragLeave += new EventHandler(UserControl1_DragLeave);
}
void UserControl1_DragLeave(object sender, EventArgs e)
{
this.BackColor = Color.FromName("Control");
}
void UserControl1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
this.BackColor = Color.Blue;
}
else
{
e.Effect = DragDropEffects.None;
}
}
void UserControl1_DragDrop(object sender, DragEventArgs e)
{
this.BackColor = Color.Yellow;
}
}
I'm open to any explanation or fix that you guys may think up!
UPDATE:
I tested using the comments listed below. STILL doesn't work. However, I have noted that it only fails while in the development environment. When I go to the bin directory and launch the program manually, it works fine. It just doesn't work when I am in the development environment, which makes debugging a bit difficult. Still looking for the big-picture fix.
A likely failure cause here is UIPI, the user interface component of UAC. You cannot drag from a non-elevated process and drop to a window owned by an elevated process. You'll trigger this when you started Visual Studio from a shortcut that has the "Run this program as an administrator" option in the Compatibility tab turned on. The only workaround is to turn that option off. Or to run it directly from the .exe file, as you discovered.

Add a WPF UserControl to a TaskPane

I am developing an addin to Microsoft Outlook.
The following code works fine if I use an winforms UserControl:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
var testControlView1 = new UserControl1();
var MyCustomPane = this.CustomTaskPanes.Add(testControlView, "Hello");
}
How can I do it with a WPF UserControl, instead? Does anybody know how I would achieve similar functionality?
As far as I can tell the CustomTaskPanes only allow Winforms Controls to be added to it.
Just found a solution,
https://stevepietrekweblog.wordpress.com/2009/03/24/vsto-display-wpf-user-control-in-custom-task-pane/
This update was just to update the link.

Putting a WPF UserControl on the TaskPane of an Excel2007 Addin

I am making a Excel Addin in VS2010.
The following code work fines if I make a winforms usercontrol
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
var testControlView1 = new UserControl1();
var MyCustomPane = this.CustomTaskPanes.Add(testControlView, "Hello");
}
However I would like to make my UserControl1 be a WPF UserControl. Does anybody know how I would achieve similar functionality or an alternate approach?
As far as I can tell the CustomTaskPanes only allows Winforms Controls to be added to it.
Answer summary:
1. Add a .net winforms usercontrol
2. Add a SWF.Integration.ElementHost control to the user control.
3. Add a Wpf control to your project seperately (not to the user control).
3. Use the Hosted Content property (hostedcontentName) of the ElementHost control and set it to the wpf control.
I found this blog post that answered it great...

Resources