Nested UserControls in Windows Phone - xaml

I am trying to create a Windows Phone app that will take use a similar UI element in multiple user controls.
One user control is loaded by the main xaml and this user control consists of another user controls. The user controls are all in the same directory below where the main xaml exists.
I get an XamlParseException on the following line in my g.i.cs file for the nested control:
System.Windows.Application.LoadComponent(this, new System.Uri("/MyApp;component/UI/NestedControl.xaml", System.UriKind.Relative));
I think it is doubling the component/UI portions of the path as the parent user control already resides in this directory.
Does anyone know how to solve this?

This exception typically means that the XAML parser cannot find the referenced XAML, or that you have invalid XAML for your NestedControl class.
Without further code, it is hard to determine the root cause. I would suggest deleting these classes until your project compiles, then slowly adding them back again, compiling each time. This will help you identify where the problem lies.

Related

VB.NET - Export hidden form as application.

It is possible to export one hidden form as a fully application including icon?
Form example I have two forms, the main one with one button and the hidden one with a message box on loading event. What I want is after the button from first form is pressed the hidden from (form2) to be built as a standalone application in a path selected by me with an icon from a selected path or from resources.
If this is impossible I heard about one method where you first create an application, then you combine the code from something1.vb and something2.vb, then you can use them to compile in another application.
Sorry for this bad explained request. Thank you so much!
No. It´s not possible to compile code at runtime - if I understood what you need.
You can at maximum:
1 - Create an EXE application and ZIP it.
2 - In your 1st form, unzip the application into a folder.
But certainly you will have troubles with antivirus and, in the best situation, in your unziped application since it wasn´t correctly installed.

System.Drawing.Bitmap error

I have a project with several forms that contain a picturebox (which sometimes contains an image). When I debug my project, I get an error message that says: "System.Drawing.Bitmap". After placing breakpoints in my code, I removed the picturebox from the form. When I go to the next form that contains a picturebox, I get the same error again...
I can't keep deleting all the pictureboxes. I need a solution. Problem is I can't really find any similar problems. I guess there is something wrong with some kind of references of the images or they are not being found...
My project is made for mobile devices / PDA's or Windows CE and written in VB.net.
Are you using the same picture in multiple places? Are the images being disposed or cloned correctly?
If you use the same image multiple times, try calling .Clone (but don't forget to call .Dispose when you are done with the clone)
How are the images being loaded / stored?

Undefined UserControl error

I just created a UserControl in my application, the problem I have is that every time I edit the code of UserControl I have to delete the UserControls already added to the GUI because it fails to compile.
The project / application is called Panel and UserControl called TimerPanel, which contains a couple of text boxes within a GroupBox.
The error reads
Type 'Panel.TimerPanel' is not defined.
The strange thing is that everything works OK until I edit the UserControl.
Like I said, if I delete the UserControl GUI, compiled and then added again to the GUI control, everything works OK.
I read somewhere on this forum that you must add a reference to System.Windows.Forms, and I did and it behaves the same.
What can I be doing wrong?
When you get that error go and build the project again, see if that fixes the issue (building a project again fixes lots of errors and when you add/change a user control is needed to use it)

Windows 8 - getting a reference to the main Page from a UserControl

In my sample Windows 8 app I have a Popup UserControl serving as a custom SettingsPane where I want to let to choose MainPage background color.
The problem is I can’t access MainPage’s children from UserControl’s code behind file - I named the root grid and I still get the error The name “mainGrid” doesn’t exist in the current context. I know this issue has been solved for WPF but none of these solutions seems to work for a Windows 8 app.
Simply pass a reference to Main when you use the user control. Have this as a property on your user control that you set at runtime.
Another option is that if you need to do operation X when something happens in the user control you can simply define an event in your user control, and implement an event handler for that event in your MainPage.

Referencing user controls that are contained within the same VB.NET project

I do apologize if this post is a duplicate, but I haven't found anything similar when I searched.
I'm fairly new to VB.NET and I'm currently playing around with user controls, figuring out good programming practices. As far as I understand, to create and use a UserControl, I need to create a project with the UserControl in it, then build the project and use that DLL (add it to Toolbox or otherwise).
My question is this: Is there a way a have a project (a Form with a bunch of things on it) that contains a UserControl written in a *.vb file inside that same Project? If you do that, the DLL (in my case) never gets produced, possibly because the UserControl is never used and building it is simply omitted. Is it perhaps a bad practice to do that altogether? It simply makes sense to me to keep a UserControl as a part of the Project that uniquely uses it. Is there a reason not to do that?
Thanks in advance! = )
SOLUTION:
Visual Studio does not automatically include your own controls to the toolbox by default! In order to change that, go to Tools>Options>Windows Form Designer>General and set AutoToolboxPopulate to True. When you build your project next time, your new Control will appear in your Toolbox.
It's a perfectly valid design decision to include a UserControl in a WinForm or WPF project that uses it. If you do this then VS will not create a DLL for the UserControl; instead the UserControl will be built into the assembly your project is producing.
If you did want to reuse a UserControl in multiple projects then you would want to create separate project that generates a DLL that can be reused.