I have developed an application using TileControl
and on Clicking the Tiles, it is navigating to forms.
The forms contains GridControl and when I am performing double click event on gridview,it is navigating to another form and displaying a result.
Now the Problem is, when i am clicking the back button of Tile Menu,it is directly showing the main menu,instead of form having GridControl.
I want to show the GridControl first and then the Main Menu.
Please help me with a solution.
I far as I can see you are using the DocumentManager and it's WindowsUIView.
To make it possible to navigate back from the current screen(with item detail) to upper level(with grid) you should make the current content container aware to it's parent container via ContentConteiner.Parent property.
Thus your containers hierarchy should looks like this:
// mainTileContainer(MainMenu)
// -> gridItemsPage(GridControl)
// -> itemDetailPage(DetailForm)
//...
mainTileContainer.ActivationTarget = gridItemsPage;
gridItemsPage.Parent = mainTileContainer;
itemDetailPage.Parent = gridItemsPage;
Related links:
Content Containers
Hierarchy and Screens
How To: Create Content Containers Hierarchy
Related
I am new in WPF and want to create WPF application like cookbook. I already done this and app work correctly. But I make it in this way:
First screen show buttons, which open new windows to do something. As a result i have 14 different windows. It is ok, but now i want to make it in other way.
I am trying to make one window, which will be showed at start, and change content. I divided window on two grids. First is static and is placed on bottom. It contains buttons, which represents functionality of the program. Second one will be dynamic. There i want to show content of every window. So i want to change content of this panel instead of creating new windows.
I tried to make *.cs files which will create controls in code-behind, functions and data. But my idea is not succesful and i do not know how to do this.
At all, I want to create app, which will work like this:
- if you click button "Add receip" then app will show controls to add name, ingredients and save it at the end.
- if you clik "Show receip" previous content will be replaced by list of ingredients
and etc.
I hope you will understand me.
You can create a Frame instead of second grid. Frame allows you to show pages, and not in seperate windows, in Frame itself. You can navigate the frame into the page like
mainFrame.Source = new Uri("Page1.xaml",UriKind.Relative);
This changes the frame to your page. You can change the source again, if you wanna change the page again.
Note: You can add tags to your buttons like "showReceip" and you can make just one buttonclick event for your buttons. Code will look like this.
mainFrame.Source = new Uri((sender as Button).Tag.ToString() + ".xaml",UriKind.Relative);
That takes the tag of your clicked button, add the string ".xaml" on it and take it on the source part. So, if your tag is "Page1", Source will look like "Page1.xaml" as my solution.
Appreciate the try, I hope you are looking for WPF user controls instead for separate windows. User controls are similar to windows you can create the UI and functionalities in the user control. I would like to recommend you to design the main window like the following:
<Grid>
<Canvas Name="canFunctionalButtons">
<!--Define the buttons inside this canvas
And allocate proper place for this in the UI
-->
</Canvas>
<Canvas Name="canControlContainer">
<!--This is to display the user control
Which can be changed dynamically according to the Button's click
-->
</Canvas>
</Grid>
Then you have to add click event for those buttons, which will add specific user control to the canControlContainer canvas. An example for adding an user control to this canvas is as follows, Let btnAddSomething be a button and btnAddSomething_Click be its click event then you can do something like:
private void btnAddSomething_Click(object sender, RoutedEventArgs e)
{
canControlContainer.Children.Clear(); // will remove previous contols from this canvas
// UC_AddSomething be the user control that you wanted to add here
canControlContainer.Children.Add(new UC_AddSomething());
}
I have a requirement to add a Window control inside a panel.
Of course this doesn't seem possible:
Window must be the root of the tree. Cannot add Window as a child of Visual.
The problem boils down to drawing the Window Chrome (control box, title bar, minimize/restore/close button and borders) inside a panel using the OS theme configured by the user. Are there any workarounds I should be investigating?
This is what User Controls are for - creating controls that can be reused in multiple windows. Refactor your Window Control so that it is just a Window that contains a single User Control (which in turn contains everything your window previously had). Place the User Control in your Panel. The idea is that your current window (that you want to be a child, we'll call it Window B) looks something like this:
Window B -> Grid/Panel -> Other Controls
And should instead look like this
Window B -> Grid/Panel -> User Control B -> Grid/Panel -> Other Controls
And now other other window can look like this:
Window A -> Grid/Panel -> ... -> Panel -> User Control B
If you're trying to achieve an MDI like interface, you have a few options - use tab controls, use a panel that can be dragged and/or resized, etc. In this case, you would still want a User Control, so that it could easily be reused in different windows (or panels) that you create, especially if you end up having to create those panels programatically (e.g. if you intend to create multiple instances dynamically at runtime).
In this case, you'll probably want two user controls: one that has all the controls from your other window, and one that would act as a "window" control within your main window. The "Window" control would have functionality for resizing, docking, etc.
WPF does not support creating a window as if it were a control, or as a child of another window (the closest you can get to that is having a window be shown as a modal dialog).
As the only answer is completely off topic, here is the best answer I can come up with:
Create window, render window as Bitmap, put bitmap inside panel.
I have got a requirement to design a windows forms application using Visual Studio 2010.
According to the design I have to develop the application which contains a menu bar. On selecting of the menus from the Menu bar relevant forms should open. Now as per my requirement these menu forms should be displayed in the same parent Windows Form. Means everything should be in the single form Application.Nothing should be out of that.
The problem that I'm facing is that I don't know how to proceed with this. This is the first time I'm working on Windows Form Application leaving Web.
You are looking for developing an MDI application. MSDN article to guide you - http://msdn.microsoft.com/en-us/library/xyhh2e7e(v=vs.100).aspx
You could build a grid area on your form using a combination of split containers (horizontal and vertical).
Then in separate panels design each of your menu forms, with each panel visibility set to false.
When choosing a menu you would need to assign a parent (split container panel) to the menu form and set it to visible.
Step 1
Create a form and give the name it to "mdiMain" and set the property IsMdiContainer to true.
Add a MenuStrip control from the ToolBar and add some menues.
Step 2
Create another form and give the name it to "frmChild"
Step 3
Write some code in menu click event to display frmChild form in MDI Parent.
Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()
Now your application is ready. You can place your code and control in frmChild window form.
As an option in some cases you can use WebBrowser control and manipulate html code inside depending on the menu bar selection.
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser%28v=vs.110%29.aspx
I would like to know how I could possibly modulate my views in an application. Let me explain.
Instead of building my view and adding all the components in one screen. I want to say put each panel in its own class / form and then have a main form where I can add and remove these 'modular' panels.
Is this possible and how would I go about doing it?
In Windows Forms there is the concept of an empty component called UserControl, that can be freely designed and added at any time to another component or form container. UserControls are used very often in order to create flexible and exchangable UI. You can create a UserControl item in Visual Studio like this:
Name the new control:
After that you can design your UI control:
When your are done with the design, compile your project/solution and go to the form where you want to add your newly designed control. In the toolbar panel you will see your new UserControl, which can be added to the form with drag & drop (with the mouse):
You can create as many UserControls as you want and add/remove them to/from your form.
All of this steps can be done completely in the code. In order to create new view of this kind, you need to create a new class that inherits the predefined UserControl class:
public class EditorUserControl : UserControl
{
}
Every Control element has a ControlsCollection that holds/contains components of type Control that are drawn when the UI is shown. In order to add your new control to the main panel you need to add it to the controls collection:
public partial class EditorUserControl : UserControl
{
public EditorUserControl()
{
var button = new Button();
button.Text = "Import";
this.Controls.Add(button);
}
}
Note, that when adding components manually, you are responsible for sizing and position them. Predefined layout panels can help you here:
TableLayoutPanel - layout with cells
SplitPanel - horizontal or vertical predefined resizable panels
etc.
Now all that left is to add the new user control to the main form just like you added the UI elements to your own control:
var simpleEditor = new EditorUserControl();
simpleEditor.Dock = DockStyle.Fill;
this.Controls.Add(simpleEditor);
You can adjust the UI control settings through its predefined properties.
You can mix predefined containers and UserControls in order to achieve the desired UI:
There are a lot of good beginners tutorials for C# and VS and .NET:
Channel9 tutorials
MSDN Visual Studio UI tutorials
Composite UserControl tutorial
Developing with Windows Forms Documentation and Examples
This is definitely possible. I will use WinForms but there are similar ways in WPF such as frames.
In WinForms you can create a new User Control for each 'modular' panel which will automatically create .cs and .designer.cs files just like in a normal Form. You can then add logic and functionality to the panels as if they were forms themselves. All that would then remain is to add the logic to the form to load the default panel on startup and think of ways of how other panels can be brought into view (e.g. a next button or having a panel on each tab in a tab control). Showing a panel in a form (or any other user control for that matter) is achieved by creating an instance of your desired panel and adding it to you form/control's Controls property like so:
public Form1()
{
InitializeComponent();
MyPanel panel = new MyPanel();
this.Controls.Add(panel);
}
I'm having a difficulty in sizing my form!
I dynamically create buttons on a form and need to know if they are all fully visible or if I need to grow the form and in what direction to make all the buttons fully visible.
I don't want to use the autosize property as I need to control the layout.
So how do I tell if a dynamically created controls bounds are within that of the form?
thanks
This a .Net 4 classic forms app.
When you add the button to the controls collection, to see if it is visible check the contains on the forms bounds - Form.Bounds.Contains(button.Bounds));. If that returns false then you need grow your form. Here is some basic code to do the form growing, it will not necessarily produce the prettiest output and is not necessarily the best way, just written to give you a quick idea of how it could be accomplished.
// Add the control
form.Controls.Add(button);
var formBounds = form.Bounds;
var controlBounds = button.Bounds;
if (!formBounds.Contains(controlBounds))
{
formBounds.Left = Math.Min(controlBounds.Left, formBounds.Left);
formBounds.Right = Math.Max(controlBounds.Right, formBounds.Right);
// Do similar for top and bottom this will ensure your button is visible
form.Bounds = formBounds;
}
Can you add the button, can't you compare the Width of the container vs the Left + Width properties of the newly added button?