Does anyone knows how to use WPF in Outlook Add-ins, I have read some blog posts and I realized that it's possible to add WPF controls in Outlook Add-in projects. I just want to host a complete WPF application in a Outlook Add-in. simple when outlook ribbon button clicks, it should open a WPF application, not a WPF controller hosted in a windows form, Can this be done?
Edited answer:
To use WPF in outlook Add-in projects, first add a WCF Usercontroller to the project and change the "UserController" to "Window" in both .XAML file and .CS file. Then you are done, You can do what ever you want with WCF.
Change this >>
<UserControl x:Class="AccessCachedContactsTest.UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>
to this >>
<Window x:Class="AccessCachedContactsTest.UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</Window>
And also change the root class of .xaml.cs file to "Window".
To use WPF in outlook Add-in projects, first add a WPF UserControl to the project and change the "UserControl" to "Window" in both .XAML file and .CS file. Then you are done, You can do what ever you want with WPF. Change this >>
<UserControl x:Class="AccessCachedContactsTest.UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>
to this >>
<Window x:Class="AccessCachedContactsTest.UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</Window>
And also change the root class of .xaml.cs file to "Window".
Related
I set the system taskbar to autohide, then I ran the WPF application in Maximized state. When the application is in maximized state, I mouse hover the bottom of the screen to view the taskbar but it does not appear. Find the code block below.
<Window x:Class="_189619.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:_189619"
mc:Ignorable="d" WindowState="Maximized"
Title="MainWindow" Height="350" Width="525">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="50" ResizeBorderThickness="3"/>
</WindowChrome.WindowChrome>
<Grid>
</Grid>
</Window>
Any workaround to show the TaskBar?
Thanks in Advance.
Regards,
Priyanga B
I'm having problem trying to include a winform user control in WPF. My control gets cropped whatever I try to do.
The control keeps autosizing itself even when I have not set the option.
Here's what it looks like
Here's the XAML
<Window x:Name="mainForm" x:Class="RFID.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RFID"
mc:Ignorable="d"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:sp="clr-namespace:gei1076_tools;assembly=gei1076_tools"
Title="MainWindow" Height="350" Width="755.682">
<Grid>
<WindowsFormsHost>
<sp:SerialPortConfigurator x:Name="spcConfigurator" ></sp:SerialPortConfigurator>
</WindowsFormsHost>
</Grid>
</Window>
What am I missing?
Thanks
I think I'm missing something very obvious.
I create a WPF application and a user control. Both within one project in Visual Studio. In the WPF application I want to use the user control but the compiler pretends not to know the user control:
Error 1 UserControl1 is not supported in a Windows Presentation Foundation (WPF) project
Here is the WPF application XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<UserControl1></UserControl1>
</Grid>
And this is the XAML code of my control
<UserControl x:Class="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Label>Hello World</Label>
You have missed declaration of the namespace in your xaml:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525">
<Grid>
<local:UserControl1></local:UserControl1>
</Grid>
</Window>
I have a WPF window which is positioned incorrectly when shown.
I want it to be positioned correctly, like this:
How may I accomplish this?
This is the xaml for the window:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WpfApplication9.MainWindow"
Title="MainWindow" Height="1050" Width="910" Background="{x:Null}" >
There's a very handy XAML tag called WindowStartupLocation that allows you to specify where it starts. It is used like this:
<Window
...
Title="MainWindow"
Height="1050"
Width="910"
Background="{x:Null}"
WindowStartupLocation="CenterScreen">
This will start it in the center of the window where the mouse pointer is.
Edit: There is also an option called CenterOwner if you want it to always be the same monitor you start your app on.
Try the following (it will bind the top of your window to the top of the screen):
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WpfApplication9.MainWindow"
Title="MainWindow" Height="1050" Width="910" Background="{x:Null}" WindowStartupLocation="Manual" Top="0">
I am trying to create a extension from an existing view where I have a list of text controls and in the new project I would like to use this control and change one of these text boxes to a radio button.
Using MVVM makes it easy to use the same code without having duplicated code, but for the XAML view I find no good way to do this change without creating a copy.
Example:
Core project with the main user control
<UserControl x:Class="SilverlightApplication4.MainPage" Name="test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<TextBlock>
asdfasdf
this is a test
</TextBlock>
<Button Height="120" Name="asdf" Content="This is a Button">
</Button>
</StackPanel>
</Grid>
</UserControl>
Now I have a second project where I want to change the TextBlock to something else.
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
xmlns:core="clr-namespace:SilverlightApplication4;assembly=SilverlightApplication4" d:DesignHeight="300" d:DesignWidth="400">
<core:MainPage>
<!-- how do i change the type of child elements?-->
</core:MainPage>
</UserControl>
Solution will be to use a ContentControl and bind it to a ViewModel through Caliburn.Micro.
I added an example and code to my other question (below the XAML section): Project structure for EF/Silverlight application