WPF XAML Encoding Error - wpf

I opened Login.XAML file in VS2012, it showing Encoding dialog box shown below
After clicking OK
I didn't see any design content of mine. I googled out but I didn't find any solution.

By clicking the encoding, or by something done previously, you've put in a character that Unicode or windows doesn't recognize. Scour your code or click on the error and you should find out how to fix it.

Related

Windows form has disappeared in Visual Studio form designer

Yesterday I edited a form in Visual Studio's form designer. When I returned to it today, the designer shows nothing. I can open the properties window, select all the different constituent components and edit their properties, but they do not show up. The application builds fine and the form can be run as usual.
I've tried a couple of different solutions, such as checking the .csproj file has the form.Designer.cs included, but nothing has worked.
Strangely, I did see this problem earlier in the week, but it fixed itself when I unlocked my computer after returning from a coffee break.
Any suggestions?
I face a similar problem in Visual Studio 2019.
To help others who may have this issue.
The problem is due to the class declaration in the Form1.cs file.
Please ensure public partial class Form1: Form class is the first-class declared in the file. No other class declaration should be on top of this.
As described in this answer: https://stackoverflow.com/a/40243490/8887398
Thanks,
Sankar
I had similar issues in VS2019. I resolved it by using:
Window > Reset Window Layout.
Then double clicked on the Form in the Solution Explorer.
Prior to this, double clicking the form was having no effect.
Weird, after trying for an hour I ended up solving the issue 30 seconds after posting this!
I edited the size property of an item on the form using the properties tab, saved the form, and then reverted the form.cs, form.designer.cs, and form.resx files to the latest source control version.
At this point the form jollily re-appeared.
Edit: FWIW, this didn't work with another form which was exhibiting the same problem.
Edit 2: That other form has now fixed itself after coming back from lunch and unlocking my PC... Might be something to do with how that affects the display - everything shifts over to my right hand monitor when I do that.
Edit 3: OK, now it seems that modifying my display DPI fixes it. On Windows 10 go to System Settings -> Display, and then move the "Change the size of text: 100%" option to say 200%. Once this changes on screen, move it back to 100%.
This seems quite foolproof, although you sometimes have to jimmy it around a lot before it finally works. I know it has worked when I get both a vertical and horizontal scrollbar; the form is then further down the page.
Just go to Form1.cs (Form1 is the name of your form), if you are able to see your source code then press Shift + F7. The form will show up.
I also had a similar issue in VS2019.
My form [Design] was listed in the solution explorer but the code was not listed as a sub-item of that form.
I could access the code by right-clicking on the form in the solution explorer and choosing view code.
What seemed to solve the problem was to close down VS2019 and simply re-open it up.
A Message appeared (with Errors and Warnings) for me which said that the first mentioned class in a cs code file must be the form class. I shifted my form class to the top of the files and everything was fine.
There are actually a few reasons that one might encounter this issue.
At times, it can be due a problem within the VS IDE and the way it incorrectly manages file types and subtypes. It normally does a great job with this "automagically", but it can also make painful and unexpected mistakes.
If you right-mouse-click (RMC) your Project, and unload it (not your solution) you will be able to RMC it again and choose "Edit Project File". Once there, search for your Form name. In my case, I will search for Form1.cs, note the incorrect icon I saw in the Solution Explorer View, and the code describing my form, within the project file:
<...>
<Compile Include="Form1.cs"/>
<...>
Change this declarative statement to the following, adding the "Form" subtype:
<...>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<...>
Save your project file, then RMC on your project name in the Solution Explorer, choose "Reload Project", and you will see the correct icon as expected, and once again be able to use the form in Design mode:
*Note: This issue shouldn't occur with default forms (named Form1, Form2, etc) and even in my case, it happened with a form I named other than the default form name. I used that name in this example, purely for illustrative purposes.
Hopefully, this helps someone.
Wishing you all the best!
I hadn't changed anything that would have broken my form, yet it still wouldn't load when I tried view designer. Restarted VS2019 and it worked after that. Give that a go before you try anything else!
I had the same problem.
My solution was to remove and add again the System.Windows.Forms reference.
Go to Tools > Options > Environment > Preview Features and select the Use the preview Windows Forms designer ...
Then restart

wxwidgets combobox read-only on Windows

I have a wxwidgets (2.8) app that works great on Linux but on Windows the combo boxes are suddenly read-only. What do I need to do to get it to allow typing on Windows too? I process text events but I can't get characters typed to be recognized. Is there anything special on Windows that needs to be done?
In essence I am trying to use the combo box as a filtering select (like an autocomplete) and it works fine on Linux. Is something seriously wrong here on Windows?
Now, I am using wxperl and I have looked at the documentation, but when I type in the combo box on Linux/GTK it works but on Windows nothing appears. Am I missing a styling option or something? What differences in underlying widgets can account for this?
EDIT On further investigation they don't appear to be fully read only, but the text event seems to remove the text in the box, so this appears to be an issue with event handling. In essence, how do I process a text event without losing the value?
I found the problem. The issue is that Clear clears the value of the combo box on Windows but not on GTK. The solutions to fix the problem are not as readily portable across platforms as I would like but that is not that unexpected.

WPF designer not showing anymore

I have a very strange problem with my Visual Studio 2010 SP1 installation on a 64 bit system.
When I double click a xaml file in the solution explorer, nothing happens. The Designer doesn't show. However, when I CTRL + Tab, the file appears in the "Active Files" list.
Anyone has encountered this before? Is this a know bug? I couldn't find anything on the net...
I would check that the designer isnt simply being hidden away. Try (Menu) View > Designer or Shift+F7
Right click the xaml file, select Open With.... Which is the default editor? It should be Windows Presentation Foundation Designer.
Just to finish this question:
After some weeks it started working again. Never found out why or why it stopped working...

WPF Control files are opening as Text Files on Visual Studio 2008

Though other types of files open fine and Auto completion is working, but Usercontrol(XAML files) appear as plain text with no syntax highlighting.
I went to the Text Editor section under Tools->Options and, whenever I tried to bring up the Formatting options for XAML, it says an error occurred.
It was working fine, but I had to uninstall/reinstall VS 2008 for some other issue and it's not working now.
Have you tried using "devenv /resetsettings" or "devenv /ResetSkipPkgs" ?
I remember having similar issue a long time ago, and was able to fix it by using some command-line reset of the IDE.

WPF DocumentViewer doesn't show the document

I'm using a DocumentViewer to view a FixedDocument and on 2 machines (out of over 500) the document viewer does not show the document.
Edit: ok, it's not a bug in WPF and the DocumentViewer control works perfectly, I'm leaving this question unchanged in case someone else hits the same problem, see my answer for the solution.
The document viewer is using a custom ControlTemplate based on this MSDN sample (mostly to remove the search box)
The toolbar, scrollbar and background all show up but the scrollbar is disabled and the content are is blank (background color)
I'm sure the document is ok because printing the document works.
I don't have any access to those machines, one of them is running Vista in what looks like a standard configuration, I don't even know what version of Window the other one is running.
The application is targeting .net 3.5
Did anyone here ever had a similar problem? do you have any idea what's causing it?
Thanks.
Here's what happened, I was using PrintDialog to get the default printer's paper size in order to create the FixedDocument, according to the docs and all my tests you can use PrintDialog without actually opening the dialog or actually printing anything and everything works just fine.
But on some computers (probably due to misbehaving printer drivers) this doesn't work, so on those computers the returned paper size was incorrect, I actually don't know it the size was too small or two big but it caused the code generating the FixedDocument to fail some internal sanity check and produce and empty document - that the DocumentViewer control then displayed correctly by showing nothing.

Resources