I would like to have master WPF form with tab control where each tab contains one independent WPF form. Those forms do not depend on each other, so I thought it will be easier to develop each of them separately and then just embed them into master form.
Number of forms is known, so there is no need for dynamic plugin system.
When you use a Frame or NavigationWindow you can have it load different xaml Pages and even html. You can also make it act like a browser with forward and backward navigation. See http://msdn.microsoft.com/en-us/library/ms750478.aspx
You could put a Frame on each tab and have it load a certain Page.
<Window x:Class="PluginApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<DockPanel>
<Frame Name="frame" NavigationUIVisibility="Visible" Source="SomePage.xaml" />
</DockPanel>
</Window>
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="Page Title"
WindowWidth="500"
WindowHeight="200">
Hello world
</Page>
Make the child forms derive from UserControl, in the master form add a tab control with one of those user controls inside each tab.
I prefer make this with userControl
First create User control
after, include reference of this userControle in another place
anywhere in the frmHome...
<DockPanel>
<Entity:ucContactList/>
</DockPanel>
Related
I am working on to WPF with MVVM pattern and created multiple user control and load it on main window as per need. only one user control is to be loaded on main window at a time.
I want to get the name of active user control from main window.
<Window x:Class="MyApp.Win.UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="MainWindowForm" Title="Sample App" WindowState="Maximized"
ResizeMode="NoResize" Closed="Window_Closed" KeyDown="Window_KeyDown" >
<Grid>
<StackPanel Name="contentgrid" Panel.ZIndex="1" >
//Load user controls dynamically as per need
// 1 user control is to be load at a time
// i want to skip background worker on some user control thats why i want to get the active user control name
</StackPanel>
</Grid>
</Window>
Application.Current.MainWindow.Content
This will give you the active content. If your user control is wrapped with any containers, you may need to iterate the visual tree and get it.
I have added Awesomium webcontrol in my WPF Page (Frame Navigation)
But its not loading any webcontent, but if i add the webcontrol in WPF Window, its working fine.
Please suggest me how to load a Awesomium webcontrol within WPF Page control
Below is the code which i am using in my application
Thanks in advance.
<Page x:Class="Project15A.SocialMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Project15A"
xmlns:my1="clr-namespace:Project15A.Controls"
xmlns:my2="http://schemas.awesomium.com/winfx"
MinHeight="300" MinWidth="500" Title="Project15A"
Loaded="Window1_Loaded">
<Grid Background="White">
<my2:WebControl HorizontalAlignment="Left" Margin="154,65,0,0"
Name="webControl1" VerticalAlignment="Top"
Source="http://www.google.com" />
</Grid>
</Page>
So I figured this one out. It is not a bug in Awesomium. (Though I think it should be on a quick start page.)
Awesomium supports two view modes. Offscreen and Windowed.
Offscreen is something that very manual. All input goes through you. (Why the default events don't still fire is kind of odd). I think this is the mode you will end up using if you want to interact with your HTML.
But if you want a normal imbedded browser window then you need to turn on the Window view mode.
Here is an example:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:awe="http://schemas.awesomium.com/winfx"
x:Class="WpfAndSpa.MainWindow">
<Grid>
<awe:WebControl x:Name="WebControl"
ViewType="Window" <--------------+
Source="http://google.com"/> |
</Grid> |
</Window> |
|
This is the key part -----------------------------------------+
I am working on a WPF project which implements the MVVM architecture. I have a requirement where, a click on a hyperlink in one view(ux){Usercontrol} should open another view(window). I am able to load a view(usercontrol) through another view(window) by simply mentioning namespace:UsercontrolViewName in the host view, but I am clueless about how to do it through a hyperlink.
<UserControl x:Class="CCSAdvantage.AddOn.UX.DisplayPhoneNumbersView"
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:res="clr-namespace:CCSAdvantage.AddOn.UX.Internationalization"
xmlns:local="clr-namespace:CCSAdvantage.AddOn.UX"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d>
<Grid>
<TextBlock Grid.Row="0">
<HyperlinkNavigateUri="">AdditionalPhone(s)/Manage</Hyperlink>
</TextBlock>
</Grid>
</UserControl>
This is the code for my UserControl, the Grid has other elements but I eliminated the details for simplicity. Additional Phone(s)/Manage => On clicking this link, a new window view which is also in xaml should open up. I tried giving the Window views name in the navigateuri property, but it does not work
Any help is appreciated. Thanks!
My problem was accessing the another view(v2) from the current view(v1), I am in. This can be achieved by using a delegate which is called at runtime in the v1's viewmodel, which calls window loader function in V2, this would load the window view(v2)
Check this Hyperlink in WPF Application.
I'm trying to create a custom WPF control and place it inside of a StackPanel in my XAML file. I originally made a custom UserControl and got the following error message:
A value of type 'CustomControl' cannot be added to a collection or dictionary of type 'UIElementCollection'.
I tried changing my custom control from a UserControl to a UIElement, but I still get this message. How do I make a custom control that I can place inside of the StackPanel?
Restart Visual Studio. The XAML designer is a notoriously sensitive beast.
How are you creating the CustomControl? Make sure it is inheriting from UserControl.
I just created a new project called "TestProj" - right clicked in the solution explorer Add=>UserControl and named it CustomControl.
I was able to insert it via the following code:
<Window x:Class="TestProj.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestProj"
Title="MainWindow" Height="350" Width="525">
<Grid>
<StackPanel>
<local:CustomControl/>
</StackPanel>
</Grid>
This could also happen if you're subclassing another control class, but your .xaml.cs file is still subclassing UserControl.
I am producing graphics for a process control system and I would like to create a system border which would visually wrap the various sub system being displayed in the process mimic. I could use a regular border for this except I want it to not only changing color reflecting system status, but also popping up small "balloons" indicating the piece of the system that is in alarm state.
I created a test project with a User Control and added a ListBox (for the balloons) and a ContentPresenter element wrapped in a border control. However, whenever I use this new control in another app, it wont allow me to add content to it. I've tried messing some with the ContentPropertyAttribute and properties of the ContentPresenter element, but I feel I am in the blind here.
<UserControl x:Class="SystemStatusBorder.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">
<Canvas Height="290" Width="303">
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentPresenter/>
</Border>
<ListBox Canvas.Right="0" Canvas.Bottom="0">
<ListBox.RenderTransform>
<TranslateTransform X="20"></TranslateTransform>
</ListBox.RenderTransform>
<ListBoxItem>TagA</ListBoxItem>
<ListBoxItem>TagB</ListBoxItem>
</ListBox>
</Canvas>
</UserControl>
I don't get it. What more should it need other than just the existence of a contentpresenter? UserControl subclasses ContentControl so I would have thought the wiring was in place. Eventually, I want it to be used something like this:
<SystemBorder>
<SystemBorder.MonitoredTags>
<List of relevant tags for the specific sub system goes here>
</SystemBorder.MonitoredTags>
<regular content goes here>
</SystemBorder>
To create your own container control, you must create a new custom control (not a UserControl).
Make your new control inherit from ContentControl.
Custom Controls don't have their own XAML. Instead, they are assigned a ControlTemplate.
When you create your first Custom Control, the IDE will create a new file Themes\Generic.xaml.
This is where the template for your control is. You can modify this template to match the XAML in your question. This will support the ContentPresenter element.
I found a very good walkthrough here.