Handling selections across multipe XAML User control - xaml

I have multiple user controls in my page. Initially I set the border thickness to zero for all the user controls.
When the user selects a particular control instance through mouse or touch events, I want the border to be shown with specific thickness.
Later when the mouse moves out of the control or when the user selects another control instance I want the border to be shown for this newly selected control and reset the border thickness to zero for the previously selected control.
How can I achieve this in XAML?

Related

Programmatically know if a control (or empty cell) is merged in Access Form

I'm working with MS Access VBA, an I have an stacked design in a form (the yellow grid).
it's possible to know (programmatically) if a control (or empty cell) is in merged cell or not?
Thanks.
These are not cells, these are controls (labels, textboxes, comboboxes, etc). Controls are not merged. What you see is a grouped layout. Controls are associated as a group and controls will move together if you grab and drag the box in upper left. Resize width of one control and you resize all in same "column"; resize height and you resize all in same "row". Forms and reports built by Access wizards default to grouped layout. To remove grouping: select a group > right click > Layout > Remove layout.
To determine the layout type of a control, reference its Layout property.
Me.controlname.Layout
0 = not grouped
1 = tabular
2 = stacked

Resize Panel Size On Windows Form Vb.net

I have 2 panels on windows form and both occupied the equal portion on form (i.e. 50%- 50%). Once i run the application, I want to resize the panel size by dragging form with mouse (i.e. 25%-75%). The portion given is not fixed it can be in any size. I just want to resize the panel by dragging/streching mouse.
Please help to resolve the issue.
Thanks,
Soorajbhan kuntal
I think you want to use a SplitContainer control on your form. Put the Panel controls into the two different containers of the SplitContainer, and set their Dock property to Fill. You can set the SplitContainer to Dock.Fill too or set the Anchor properties such that the SplitContainer stretches along with the form.

Overlapping controls - Canvas.ZIndex not working

Background:
For my Windows Phone application, I have created a UserControl called CharacterPresenter (let's call it CP, for short). This is a small rectangle with a Border control which I can toggle between PhoneAccentBrush and Transparent so the user can see when it is selected.
I have created a second UserControl called MultiCharacterPresenter (MCP). This contains a horizontally-oriented StackPanel to display multiple CP controls on a single line. This too has a Border control so the user can see when the whole line is selected.
Note that only one *Presenter can be selected at any time and all BorderThickness="6".
Requirement:
I can't have a 12px. gap (caused by the Transparent Borders) between each CP so I set the Border Margin="-6,-6,-6,-6". This puts the Border outside the rectangle bounding the CP UserControl and allows the CP controls to form one continuous line inside the MCP.
So then, when a CP is selected, the Border overlaps the neighbouring CP controls. That's fine since the selected CP has the user's focus so it's OK that other CP controls may be partially obscured.
Problem:
The issue is that the right-side of the Border of each CP is underneath the next CP on the right. Only the right-most CP shows a complete border. I want the whole Border to show when a CP is selected but it is partially hidden.
Non-solution:
I tried setting the Canvas.ZIndex of all the Border controls to 1 (while the default for all other content is zero) which should put the Border controls on top of everything else... but that didn't work. I'm not sure why.
If it makes a difference, I'm adding the CP controls one-by-one to the MCP in code, based on the data. So perhaps the ZIndex only works when all the controls are rendered at the same time, e.g. if they are already present in the XAML (not added programmatically).
Any ideas?
The layout of controls contained in any Panel relative to each other is defined by the Panel itself. In your case you're using a StackPanel, which has no concept of Z-index. It lays out items in the order that they are added to its Children collection. The ZIndex attached property you're using is defined on Canvas because it is used by the Canvas panel as part of its layout process.
Why don't you try changing the BorderThickness to 0 instead?

Increasing the space inside a windows form

I am trying to populate my windows form with new controls and data based on what is read from my database. The left side of the form is a static panel which will not need re sizing but I need to create multiple labels on the right side which requires more space. I added the vscroll control but am having trouble increasing the size of the right side of the form.
To use a scroll-bar will require a semi-low-level implementation where you need to always update the view by repositioning the elements, calculating your scroll-bar in relation to total view, what elements would be visible and so forth.
A better solution in this case will probably be to add a Panel control on the right which is docked (f.ex. Fill) and then set the AutoScroll property to True.
This way you leave all the "low level" stuff to the Panel control and you can add and position the elements you need to the Panel's Controls collection instead.

Arrange user controls dynamically on parent form in VB.NET

How can I arrange controls in my parent form by code?
So far I call the user controls with this code;
Me.ParentForm.Controls.Remove(Me)
controlMain()
I want the user controls arrange itself whenever the user resize the parent form or maximize the form. Currently, I set the controls by,
Public Sub controlMain()
Dim usrctl As New _ctlMain
_Main.Controls.Add(usrctl)
usrctl.Location = New Point(_Main.Width / 2 - usrctl.Width / 2, _Main.Height / 2 -usrctl.Height / 2)
End Sub
which is on a module. _Main is my parent form while _ctlMain is the control being called. I do not intend to put the user control on the parent form during design because I have other user controls to call after a specific function in an active control is called.
I have tried the autosize property of usercontrol but I guess it doesn't work on my application. Usercontrol doesn't have the dock and anchor properties.
Use one of the automatic layout controls, like a FlowLayoutPanel or a TableLayoutPanel.
Instead of adding your user controls to the form itself, add them to either a FlowLayoutPanel or TableLayoutPanel control that has been placed on top of the form using DockStyle.Fill.
It sounds to me like a FlowLayoutPanel is what you want. With that, the layout of the controls is handled entirely automatically, and they are positioned either in left-to-right or top-to-bottom order, depending on the value of the FlowDirection property.
The only reason to choose a TableLayoutPanel is if you need to have more precise control over the exact positioning of the controls. It works just like an HTML table, with each control getting its own "cell".
You can also set the Dock and/or Fill properties of the individual user controls if you'd like to ensure that their sizes are automatically adjusted. For example, you can set each control to fill the entire cell in which it is placed in a TableLayoutPanel.