How can I programmatically refresh Visual Studio WPF designers? - visual-studio

Is it possible to programmatically refresh WPF designer windows in Visual Studio e.g. using DTE?
I have some design-time behaviour where I would like to refresh WPF designer windows after file system changes I have detected.
I have tried:
dte.ItemOperations.OpenFile(file) //where file is a xaml file
but this has no effect.
Update
I am looking for a solution where I do not close and then re-open the xaml file, as this is too heavy-handed. I'm looking for a way of getting WPF designers to reload\refresh as they do when the solution is rebuilt.

The best that i can think of is
dte.ActiveDocument.Close(vsSaveChanges.vsSaveChangesNo);
dte.ItemOperations.OpenFile(FileName);

Related

Is it possible to add VSIX XAML Toolbar to Visual Studio?

Is it possible to add XAML toolbar (instead of native Visual Studio in vsct file) to Visual Studio (in this case Visual Studio Shell)?
I cannot find any examples in the Internet.
I would recommend you stick with using a VSCT resource, to keep your extension consistent with the look and feel of the IDE as a whole.
That being said, there is nothing stopping you from designing a toolwindow or custom designer that hosts XAML based toolbars. Some extenders choose to do this, but the buttons hosted are not VS commands, are not exposed to or discoverable via the Tools | Customize dialog, other extensions cannot automate or programmatically access them, and you lose the built in functionality to control visibility/enablement based on active contextUI guids.
Sincerely,

VS axml Edit and Continue in Xamarin.Android Projects

Is there any way to edit the .axml file of a Xamarin.Android project file, while debugging and see the updated changes live? Or is there any workaround for this?
I am coming from WPF and UWP, where we have the Xaml Edit and Continue feature, where you could edit the .xaml file while debugging and the changes would update the debug application in real time.
I know there is no such feature as .axml Edit and Continue in Visual Studio, but in WPF, before xaml edit and continue existed I was using the snoop workaround, where you could attach with another application to you debug application and change controls/ View Models properties live. The changes we're not persisted to the .xaml file, but it was enough for UI debugging.
The best workaround I could find is to inspect the application while debugging with Xamarin Inspector.
This won't update the .axml file, but for debugging purposes it is good enough.
Here's [minute 5:30] a short demo video on how it works.

Visual Studio 2010 To Blend 4 Not Working Right

Visual Studio and Blend 4 Design Problem
I have a VS 2010 C# solution file that I am opening in Blend 4. The file opens with no errors, however if I attempt to build it in Blend the program lists a few missing references and then crashes Blend. Here is the issue that I am really trying to solve since I think I can solve the missing references in due course. Once the solution is opened in blend the Design tool for any XAML does not display at all. VIEW >> Active Document View >> Design View, etc. are all grayed out. What is the secret to having a programmer work in VS and hand off solution files for a designer like me to work on GUI in Blend. It seems MS has made this a difficult procedure to master.
It sounds like you created the project using the Class Library project template instead of the WPF User Control Library template. When you put these two project files side by side, you'll see that the WPF User Control Library project has this additional line near the top of the project file:
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
This is what tells Blend it can display a design surface for the items in the project. There's lots of stuff you can make in Visual Studio that cannot be displayed in Blend, so Visual Studio needs some way of communicating to Blend that it should attempt to load designers. Edit your .csproj file to contain the above GUIDs and I bet it will work.

How to programmatically drop a file on a Windows app?

I'm looking to have a particular running instance of Visual Studio open a file. Is there a way I can fake a drag-drop operation via code from my app to Visual Studio? Same as if I were to drag a file from Explorer into VS.
I realize I could probably do this easier as an add-in or macro but I'm looking to make this work purely from a script.
You could try sending a WM_DROPFILES message to the Visual Studio window.

WPF Applications: Visual Studio vs. Expression Blend

I am a bit confused on how Visual Studio 2010 and Expression Blend 4 operate together. If I want to create a WPF application, should I start it in Expression Blend 4? If so, then how does Visual Studio 2010 natively open Expression Blend projects, or does it?
Or should I start my application in Visual Studio 2010? If so, how do I open my solution in Expression Blend.
Also, how do I modify an existing WPF form, if I need changes. If I already have events handled and code behind, how do I bring it over to expression blend, make my changes, then bring it back to visual studio without disrupting the events and code that I have created in Visual Studio 2010?
Also can someone recommend a good book that covers how to create WPF and/or Silverlight applications using Expression blend 4 and Visual Studio 2010 together.
Solutions are the same for Visual Studio and Expression Blend. You can open your solution through the file menu in expression blend, or by right clicking on a xaml file in Visual Studio and select "Open In Expression Blend".
Personally, when I need to make only a small change, like changing the text on a button, I don't go into Blend. But when I want to see what's going on, with margins and layout and stuff I always use Blend. Most often I have Visual Studio and Blend open side by side and I keep switching back and forth.
Because Expression Blend uses the same solution you don't have to worry about event handlers and such. When they are in place, they stay in place. Unless you delete the control the event is attached to of course.
Creating a solution can be done in both tools, but I start most projects in Visual Studio. There are however a few Project templates that can't be found in visual studio. For example the Databound Application project type. This will give you a start on an MVVM project, with folders in place for the Model, View and ViewModel.
You can have it open in both Visual Studio and Blend at the same time. You're prompted in Visual Studio if you make a change in Blend and vice versa.
Personally I create the new application in Visual Studio first then open it in Blend.
I usualy start my project in Blend.
Remember Blend is specially designed to make great UI, easy databindig, make easy templates and custom controls.
You can edit the code behind of your app directly in Blend but sometimes it doesn't show the intellisense; thats when you need open VS, to do that right click on your project inside blend and click on edit with Visual Studio. It'll launch VS and you can start coding.
You dont need to close VS or Blend, they booth can be open, if you make some change in VS it will notify Blend, will appear a dialogbox telling you: reload the app, click Yes the changes will be sincronized in Blend and VS, the same happens when you make changes in Blend and go to an already open instance of VS.
Too remember to install de VS tools, it will allow you to open Silverlight projects inside VS, if they arent already installed an error message will appear.
Hope my answer help you

Resources