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

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);

Related

Open/Load view from another project of same solution in WPF

In my application, in a single solution, there are two different project.
Lets say, Project A and Project B.
From the view of first project A, on button click event, I want to load the view from the second project B.
Could you please guide me.
Thanks.
Ruhul
Add a reference to Project B from Project A in Visual Studio: Project->Add Reference->Projects->Solution.
Then you can create an instance of the view class that is defined in Project B and use it as appropriate:
private void btnClick_In_Project_A(object sender, RoutedEventArgs e)
{
//if viewB is a window:
ProjectB.ViewB viewB = new ProjectB.ViewB();
viewB.Show();
//or if viewB is a UserControl:
Window win = new Window();
win.Content = new ProjectB.ViewB();
win.Show();
}
Project B should be a WPF User Control Library or a WPF User Control Library.

WPF app cant load image and related info into second form

Hey everyone i need help with a WPF app im writing.
it consists of 2 forms a main input window and a script(pharmacy script app) window
on the main input window it has a combobox with 2 items : clicks and dischem, depending on what is chosen there it needs to load the logo of that pharmacy into the script window.
at the top of the script window it has an image control
how can i accomplish this?
private void Button_Click(object sender, RoutedEventArgs e)
{
if (PharmacyComboBox.SelectedItem != null)
new Window2(PharmacyComboBox.SelectedItem as Image).Show();
}

How to remove or hide Component Tray from End-User ? XtraReports Winforms Devexpress?

I want to hide or remove this component tray from end-user. How to complete this task.
I agree with #DmitryG
Code from How to: Hide the Component Tray from End-Users in the Report Designer
should work
using System;
using System.Windows.Forms;
using DevExpress.XtraReports.Design;
using DevExpress.XtraReports.UserDesigner;
// ...
private void button1_Click(object sender, EventArgs e) {
// Create an End-User Designer form.
XRDesignForm designForm = new XRDesignForm();
// Handle the DesignPanelLoaded event.
designForm.DesignMdiController.DesignPanelLoaded +=
new DesignerLoadedEventHandler(DesignMdiController_DesignPanelLoaded);
// Load a report into the Designer.
designForm.OpenReport(new XtraReport1());
// Show the End-User Designer form, modally.
designForm.ShowDialog();
}
// List the components in the Report Explorer, instead of the Component Tray.
void DesignMdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) {
((XRDesignPanel)sender).ComponentVisibility = ComponentVisibility.ComponentTray;
}
Have you tried to read documentation or contact DevExpress Support?
Create an End-User Reporting Application - This document lists examples for creating and customizing end-user reporting applications on various platforms.
Example:
How to: Hide the Component Tray from End-Users in the Report Designer

ALT-TAB always activates main window in WPF app with multiple owned windows

On Windows 7, .NET 4.0 I have a problem that can be reproduced by copying the following code into a blank WPF application generated by Visual Studio:
public MainWindow()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainWindow_Loaded);
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
new Window() { Title = "Test", ShowInTaskbar = false, Owner = this }.Show();
}
Run app
Activate secondary window
Alt-Tab to other running application
Use mouse to activate our WPF app in taskbar
Now the WPF app is active again, with the secondary window activated and the main window deactivated, which is the expected (and desired) behavior.
Now do this instead (only step 4 differs):
Run app
Activate secondary window
Alt-Tab to other running application
Alt-Tab back to our WPF app
The WPF app is active again, but now the main window is activated.
Adding this code
private void Application_Activated(object sender, EventArgs e)
{
Windows[1].Activate();
}
to App.xaml.cs does not solve the problem because now in the second case both windows are activated. Also, clicking the secondary window does not deactivate the main window. I have to click the (already activated) main window and the secondary window again to achieve this.
How can I avoid this (only the secondary window should be active in both cases)?
CodeProject actually addresses this issue here, hope this is what you're looking for.
Combine with a post from Tamil Khason and in theory you can override the OnFocus event on a global level so that every time a window is on focus, that becomes the "main window" which will then be the target of ALT+TAB.
based on THIS solution the following code can maybe (not tested jet) also do the trick
protected override void OnStartup(StartupEventArgs e)
{
EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(WindowLoaded));
base.OnStartup(e);
}
void WindowLoaded(object sender, RoutedEventArgs e)
{
Window w = sender as Window;
if (w != null)
{
// this part works in my case very well
w.Owner =Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
}
}

WPF Ribbon - Can we hide AuxiliaryPane of Ribbon ApplicationMenu?

I am using MS Ribbon in my application.
I want to hide the AuxiliaryPane of its RibbonApplicationMenu ? I want to show only normal menu items.
I read that it Pane violates the Microsoft Office UI License of Ribbon Control.
But in Microsoft CRM, AuxillaryPane is not present.
So is there an option to hide this ?
Regards
GP
Try this it worked for me in Ribbonbar's loaded event
private void ribbonBar_Loaded(object sender, RoutedEventArgs e)
{
var grid = (ribbonApplicationMenu.Template.FindName("MainPaneBorder",ribbonApplicationMenu) as Border).Parent as Grid;
grid.ColumnDefinitions[2].Width = new GridLength(0);
}

Resources