Inspecting XAML in Windows 8 Store Apps / VS2012 - xaml

I'm looking for a way to inspect running XAML in a Windows 8 store app. Essentially, I want firebug / chrome inspector style functionality where I can look at the XAML source generated at runtime, to debug simple layout and style issues.
I've tried Snoop, Pistachio and WPF Inspector but none work for Windows Store apps. The only one I can find which seems to work for Store apps is XAML Spy, which is €90. I can't justify that cost.
Is there any other way to inspect running XAML?

WinRT XAML Toolkit now has an actual visual - visual tree debugger.
Get it from NuGet: nuget.org/packages/winrtxamltoolkit.Debugging then call WinRTXamlToolkit.Debugging.DC.ShowVisualTree() to display the debugger tool inside of your app. It's the third option so now you can use
the WinRTXAMLToolkit.Debugging.VisualTreeDebugger class - that enables you to debug the tree in your Visual Studio
XAML Spy - which is a great commercial visual tree debugger that runs in a separate window
and now this visual tree debugger in the WinRT XAML Toolkit that works inside of your app.

The VisualTreeDebugger class from WinRT XAML Toolkit is what you could use if you want a free tool. It doesn't do as much as XAML Spy, but you get what you pay for. I thought of adding more features to it like actual visualization of what you debug, but the work required would not justify the time investment + I didn't want to step on Koen Zwikstra's turf. I am sure he is doing a great job on that tool. Anyways - VisualTreeDebugger is enough for me, so maybe it would also be enough for you.
The way you can use it is add the class to your code, add a reference in your XAML like
xmlns:debug="WinRTXamlToolkit.Debugging"
then put a hook on a control where you would like to start debugging, like
debug:VisualTreeDebugger.BreakOnLoaded="True"
which will dump the core visual tree details as text in your debugger output window (Ctrl+W,O) and break in the code that dumped your tree where you can investigate the "path" variable, which contains the list of all visual tree elements from the debugged control to the root, so you can watch their values if what you need wasn't already dumped in the output window.
Other options include
debug:VisualTreeDebugger.BreakOnTap="True"
debug:VisualTreeDebugger.BreakOnLayoutUpdated="True"
debug:VisualTreeDebugger.BreakOnLoaded="True"
debug:VisualTreeDebugger.TraceOnTap="True"
debug:VisualTreeDebugger.TraceOnLayoutUpdated="True"
debug:VisualTreeDebugger.TraceOnLoaded="True"
Since it is source code and really a single simple class - you can easily add additional things to the code to do any custom debugging you need.

XAML Spy is what you need. You find it at http://xamlspy.com.

there is a new free tool called XAML Inspector. It's available through NuGet. Just search for "xamlinspector" or get if from the project page: www.xamlinspector.com
Greetings
Christian

Related

Missing "Define debug and define trace constant" checkbox in visual studio 2022

I'm missing two checkboxes for defining constants in my properties screen. Am I missing something?
It should look like this
I'm using a Microsoft.NET.Sdk.Web project in net6.0
Somewhere along the way, Visual Studio streamlined these options to what you are seeing instead of what you are expecting to see. Actually, I don't think this is a Visual Studio-specific change, but rather it depends on what kind of project and what SDK you are using - those being:
.NET Framework
.NET (.NET Core)
I am guessing you are coming from one of my other answers, which sparked you to ask this question. In my post, that screenshot is from a .NET Framework project. I should have probably been slightly more specific in my reply to you. In your project, you are clearly using .NET 6 (as you mentioned above). Because of that, your properties menu looks way different. This is the streamlining I am talking about.
So where are your checkboxes for defining DEBUG and TRACE constants? They are gone! However, you are looking right at the control that replaced them - or rather, you are looking at how these controls work now. Essentially, the $(DefineConstants) replaces these checkboxes, and you can specify additional constants in the same textbox, separating each by a semicolon. If you hover over the "Conditional compilation symbols" controls and click the gear icon, you can toggle it to vary by configuration, which I think is more clear and useful to do:
Then, if you wish to add custom constants, simply add them to the configurations. In the below screenshot, I added an ONLY_DEBUG to the Debug configuration, and an ONLY_Release in the Release configuration:
In the code, you can use them as so:
Microsoft Documentation can be found here.

VS 2022 Preview not showing the XAML designer

I've just installed VS 2022 preview to use Maui but there seems no way to see a designer view of the XAML, I want to drag and drop controls onto the page but all I get is an ancient looking XAML text view.
Visual Studio has removed the XAML designer. For now, there is no official plan to readd it.
But Visual Studio support Hot Reload to modify your apps managed source code while the application is running, without the need to manually pause or hit a breakpoint. You could preview the view at runtime when you change the UI. For more details, please check the blog. https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/
Like Cfun said, you could use live visual tree as well. It shows a tree view of the UI elements of your running Xamarin.Forms application. https://learn.microsoft.com/en-us/xamarin/xamarin-forms/xaml/live-visual-tree
For a WPF dotnet6 project, the XAML designer can be enabled here:
Don't know why it's disabled by default.

What Windows Forms control would be used to create a dockable window like Visual Studio Solution Explorer?

I want to be able to use things like the Solution Explorer window or the Properties window from Visual Studio in my Windows Forms application. I am not sure what the term for it is so I cannot look it up.
Have you tried using a normal panel? You might want to code all the contents of the solution explorer and the properties panel. The panel can be docked from its properties. Then, for example, if autosize is disabled, you write
If ...... Then
_something_.Autosize = false
End If
But that's a TON of code!
I don't think you can reproduce the solution explorer dynamically nor the properties panel. Besides, do you need to change all properties of an object at once? It looks like you are trying to remake visual basic dynamically. Well, that can't happen. Not with the current versions of vb.net, at least.
You should try involving things with panel that appears on your screen with all the settings in it, but like TGamer, there is a lot of code to do. But start with showing and hiding the panel to start with. Maybe try importing the settings through a VS file stored somewhere in your directory.

UWP: VS Designer Error when DesignViewModel is inheriting from reactiveui's ReactiveObject

Dear C# reactiveui community,
I am currently developping a UWP-App. To connect the UI with my BusinessLogic, I am using reactiveui in my ViewModels.
However, the VisualStudio designer keeps telling me that there is an error in my XAML when I set the DataContext or the d:DataContext to a ViewModel that extends ReactiveObject.
I keep seeing that nasty prompt to check for errors in my XAML code. The spot where I set my DataContext is underlined.
I am running Debug x86, targetting Build 10240. Experimenting with other Build targets or switching to Release did not help. To make use of the designer, I have to switch to x64 because there are no design instances in x64. That is an unacceptable solution, however.
Anybody who can help me with that issue? Thanks in advance!
I can't help with the ReactiveUI issues, but for Visual Studio 2015 you can now toggle the designer so that it does not run code in design mode. We enforce this when you switch to X64 or ARM as targets (since we can not run that code on X86) - which is why the designer then functions.
You can also toggle to 'no project code mode' using the icon next to the zoom control under the designer. Click this icon and VS2015 will no longer run code in the designer and will also show placeholder data for your bindings. Let us know if this feature helps you.

Intellisense not working for XAML in VS2012 and only partially in Blend

I'm trying to get RC of Visual Studio 2012 working for XAML files. I can't seem to get any XAML Intellisense and the option within Tools is greyed out.
I've also tried to run the solution using Blend, however I only get Intellisense for custom controls such as telerik then.
When ever I drag controls onto the design surface I get an "Object reference not set to an instance of an object" exception but the control is still added to the surface.
I've read that this was a bug within VS11 and was fixed with in the Visual Studio 2012 RC.
I've created a new Silverlight Application and the intellisense is working so i'm wondering if its an issue with how my projects are set up.
I have all of my Styles within a separate themes project, which is referenced by other all other projects. Within the designer these references show up as errors but when the application runs they are resolved fine.
Would unresolved resources at design time affect Intellisense?
Click "Build -> Clean Solution", then "Build -> Build Solution". ("Rebuild Solution" alone doesn't work.) [Source]
If you have a reference to any of the expression blend dlls for interactions and you are using silverlight5 you will need to update the following dlls:
Microsoft.Expression.Controls.dll
Microsoft.Expression.Effects.dll
Microsoft.Expression.Interactions.dll
System.Windows.Interactivity.dll
Blend + SketchFlow Preview for Microsoft Visual Studio 2012
http://www.microsoft.com/en-us/download/details.aspx?id=30702
Ref Location:
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Libraries
Exact same problem here, using WPF.
In my case, removing:
<Page.Resources>
<vm:AnyViewModel x:Key="anyViewModel" />
</Page.Resources>
Solve my problem...
One known cause of XAML Intellisense failure is if System.Windows.Controls.Toolkit is one of the project references. I've seen where deleting that reference instantly fixes the problem. The problem is described in the comments of this Connect bug for VS2012 Beta, but it applies to the RC with the July update as well.
I've found that some xaml designers for a control have this issue, where other controls are just fine.
The problem (in my case) seems to be if parameters are null or events call uninitialized singletons. Something the designer gives you a stack trace and other timers renders with no problem.
I've found by changing the back-end code for pages that don't have Intelli-sense to include DesignerProperties always fixes the issue (in my cases).
public Homing()
{
InitializeComponent();
if (DesignerProperties.GetIsInDesignMode(this))
return;
// some other code here that may have uninitialized members
}
t
I'm not sure if I had the same problem, but Intellisense mysteriously stopped working for me within a XAML file. I tried cleaning the build as someone suggested, but that didn't work.
After I restarted Visual Studio 2013, the Intellisense in the XAML page started to work again.