Latest Silverlight 4 SDK- missing properties? - silverlight-4.0

I have what I believe to be the latest SL4 SDK and tools for Visual Studio 2010. However, I seem to be missing certain properties that I would expect to be seeing.
As an example, when editing a XAML textblock control, I am not seeing the TargetNullValue, StringFormat and FallBackValue properties. I have added a reference to the System.Windows.Data but still nothing shows in the XAML editor.
Can anyone confirm whether I should be seeing these properties or is there something else I should be doing to make these properties visible?
Thanks

They show up for me.
Make sure you are setting up a proper binding:
<TextBlock x:Name="testing" Text="{Binding TargetNullValue=Value}" />

Related

Cannot get Xamarin Xaml Intellisense working in VS 2015

I've been trying to get intellisense working for quite some time now, and am unable to see anything outside of
!
![CDATA[
?
Visual Studio 2015 Update 2
Resharper is installed but disabled
Referencing the latest pre-releases of Xamarin Forms (2.3.0.38-pre2)
Xamarin for Visual Studio (4.2.21)
Portable project referencing the proper 2.3.0.38-pre2 targets file from NuGet
Enable XAML Language for Xamarin.Forms
What else am I missing? I feel like it shouldn't be this difficult.
I resolved this issue by doing a simple workaround and here is the solution.
Right-click the XAML file in the Solution Explorer and select
Solution 1: "Open With... > Source Code (Text) Editor".
and in another time this also worked for me:
Solution 2: "Open With... > Source Code (Text) Editor with Encoding"
This workaround gave me the desired XAML IntelliSense even without installing the extra "Enable XAML Language for Xamarin.Forms" extension and even with ReSharper installed but suspended.
Extensions > Tools > Enable XAML Language for Xamarin.Forms
Enable XAML Language for Xamarin.Forms
Enables the VS built-in XAML language service to provide editing and intellisense for Xamarin.Forms XAML files.
https://visualstudiogallery.msdn.microsoft.com/8195a8e2-a842-4389-a8cb-34e4672e2e13
Update:
From #Jeff:
Seems I had to completely uninstall Resharper, not just disable it. Then reinstall the "Enable XAML Language for Xamarin Forms extension".
Additional info:
http://www.cazzulino.com/enable-xaml-forms-intellisense.html
Xamarin XAML Enabled:
XML Enabled and thus no Xamarin XAML Intellisense:
The reason why Intellisense is not appear in editor is that Xamarin XAML is not opened as file with content type xaml but file with content type xml.
To open xamarin XAML file as file with content type xaml simply in solution explorer right click the xaml file and select Open With... In popup select "XAML Designer with Encoding" and click OK.
Solution below is if you edit Xamarin xaml as file with content type xml. But this solution is not correct, IntelliSense then not always correctly suggests.
To take advantage of Intellisense the Visual Studio must get appropriate definition of xml namespace for Xamarin.Forms. For the Xamarin.Forms Visual Studio needs xml definition for namespace http://xamarin.com/schemas/2014/forms.
This definition can be provided to Visual Studio by two ways:
You can use xsd file and this file then register to xml schemas - after you open xaml file, the menu Xml/Schemas appear.
You can this definition create by assembly attribute XmlnsDefinitionAttribute. This attribute you can found in Portable.Xaml nuget package.
Suitable for Xamarin.Forms is the second way(using attribute).
If you use Xaml in portable library, restore(download and install) this nuget package to this library.
If you use shared project, then restore this nuget package to all projects referencing this shared project.
Then insert this attribute to appropriate place. I believe that the App.xaml.cs(if you use generated name App) is a good place. The code could look like this:
using Portable.Xaml.Markup;
using Xamarin.Forms;
[assembly: XmlnsDefinition("http://xamarin.com/schemas/2014/forms", "Xamarin.Forms")]
namespace YourAppNamespace
{
public partial class App : Application
{
public App ()
{
this.MainPage = new MainPage();
}
}
}
And the rebuild solution, as I believe, might not be necessary to work Intellisense for Xamarin.Forms.
This worked for me:
right click on .xaml file and then select "Open With.." and select "XAML Designer" and also "Set as Default" then intellisense worked great.
I install the Extension Enable XAML Language for Xamarin.Forms from
Enable XAML Language for Xamarin.Forms
Still the intellisense was not working. I just need to close all tabs and close the visual studio. After re-starting Visual studio I open solution and XAML file. The instellisense is working fine.
worked for me
Right click on Your XAML file and choose Option
Open With=>Source Code(Text) Editor with Encoding=>Set as default=>Apply and choose option Auto....
Seems I had to completely uninstall Resharper, not just disable it. Then reinstall the Enable XAML Language for Xamarin Forms extension.
Jeff's answer almost worked for me, but I had to do one additional step:
Because I had previously uninstalled and reinstalled Xamarin, I had to update from 4.0.1 to the latest stable (4.1.1.3 as of this date). After that Intellisense started working!
I have Resharper installed on VS2015update3, and XAML Designer didn't work for me.
But accidently I found XML (Text) Editor works. That's Resharper that makes effet.
No wave-line beneath the tag
Perfect prompt everywhere: XML Tags, Properties, available Values
Only things: it doesn't color too much, and F7 do not send me to its code-behind.
VoilĂ , hope this could help
I resolved this issue by doing a simple workaround and here is the
solution.
Right-click the XAML file in the Solution Explorer and select
Solution 1: "Open With... > Source Code (Text) Editor".
and in another time this also worked for me:
Solution 2: "Open With... > Source Code (Text) Editor with Encoding"
Actually, I found that for me it even worked by simply choose:
Solution 2: "Open With... > Automatic Editor Selector (XML)" and then reopening VS.
I also found that the problem began after editing .xaml file outside of VS, by right-clicking the file and choose "Edit".

Xamarin Forms InitializeComponent does not exist

I am learning Xamarin Forms for Visual Studio 2015 and trying to create a simple Shared project using Xaml but I keep getting InitializeComponent does not exist (as well as any reference to Xaml controls in cs classes).
It is my understanding that in the latest versions of Xamarin, Xaml works in Shared Xamarin Forms Projects (and not only in PCL projects). I've tried running the latest betas that got released less than a month ago but still no luck.
Any advice is greatly appreciated.
Turns out I had to manually change the properties for all Xaml files like so:
Build Action: Embedded resource
Custom Tool: MSBuild:UpdateDesignTimeXaml
For some reason adding new Xaml forms files doesn't set these by default in VS2015 with latest Xamarin.
I had the same issue. And it turned out to be that fully qualified Class Name (x:Class attribute in the main node) in the XAML file must match exactly the xaml.cs file's name. I corrected the namespace casing and it worked!!
This happens when your XAML markup is invalid. There is a background compilation task that parses the XAML file and generates a code file (this is normally hidden from the developer) which declares those control references. If your XAML is not valid then this task will fail silently, and your first hints are the symptoms you describe.
Comment out the contents of your XAML file using standard XML comment syntax (wrap it with <!-- and -->), then rebuild your project to clear out all of the errors. You may also need to comment out some code in your .cs files temporarily to get it to build. Once you get it building, then you can go back and start uncommenting your XAML until you find the part that was breaking it.
Try it:
Open the Package Manager Console, put the follow line:
update-package -project your_pcl_project_name -reinstall

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.

Silverlight 4 user control not appearing

I'm new to SL and must be missing something really fundamental here.
I have created a very simple user control like so:-
<UserControl x:Class="Company.UI.Common.Controls.TestControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="Yellow" Width="100" Height="20">
<TextBlock Text="foo"></TextBlock>
</Grid>
</UserControl>
Then in my view I'm referencing it as follows:-
xmlns:medControls="clr-namespace:Company.UI.Common.Controls;assembly=Company.UI.Common"
Then including it in the UI like this:-
<medControls:TestControl Width="100" Height="20" Visibility="Visible" />
However nothing appears when I run the app, just an empty space 100x20 pixels where the control should be. I've used Silverlight Spy and it shows the control being present, with all the correct details - type, assembly, visibility, etc.
I have put a breakpoint in the user control's constructor, and can confirm that InitializeComponent() is being called.
Any suggestions as to what is happening would be greatly appreciated, as I'm tearing my hair out over what should be a very simple thing to do!
Thanks in advance
Andy
This turned out to be a known bug in VS2010, reported here: http://connect.microsoft.com/VisualStudio/feedback/details/683175/visual-studio-failing-to-embed-g-resources-file-in-dll-with-certain-silverlight-project-files
Basically, in some situations, the order of elements in the .csproj file can change, resulting in the XAML files not being included in the assembly, and this is what was happening with me. No runtime errors. Nothing. Just an empty space where the user control should have rendered.
The above link tells you what you need to do to resolve the problem, and involves manually editing the .csproj file and moving certain elements around.
Incidentally, this same bug was also the cause of another problem I'd been having where my user control's code-behind was referencing a control (e.g. "this.txtForename"). The control reference, which is set up in InitializeComponent using FindName(), was always null.
Hope this helps someone else.
Andrew
See if this helps:
http://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol%28v=vs.95%29.aspx
http://10rem.net/blog/2010/02/05/creating-customized-usercontrols-deriving-from-contentcontrol-in-wpf-4
I never tried to create a custom usercontrol in xaml i always did it programatically, has you can see in this examples, but you can pull it off if you use one ContentControl or one ContentPresenter and then call you UserControl

How to reference an icon resource file reference in XAML

I'm trying to get a button to display an icon in XAML. Initially I wanted to paste a character instead, but vb Express 2008 would not recognise it being a symbol as it is not a regular character. Then I created an icon and tried to set the button image property to reference it, but this does not exist, so more misery. Now I've used the project resources to add the icon file which it has shoved in the project resources directory.
What I want to do is use XAML to display the icon, in this tag:
<Button>
<Image Source="{StaticResource UpArrow}"/>
</Button>
I ideally want to have the image in a separate file and reference it by the project. I am a bit confused by the content/resource issue.
I tried to access it using:
<UserControl.Resources>
<BitmapImage x:Key="UpArrow" _
UriSource="Resources/_25B2_Triangle__black__up_pointing.ico" />
</UserControl.Resources>
I've read some stuff about the pack assembly which is massive and confusing. Surely, putting an icon into the resources file should make it easy to reference using /Resources or similar, instead of the absolute file path, otherwise, what is the point of it?
I am wanting to do it all in XAML rather than code-behind because then this work would all be done by the client, but maybe I am not undestanding when to use code behind. With WPF, there is very little written about what you are trying to do at the large scale and why you would want to do it, apart from MS constant refrain of how 'cool' it is, -which is not very helpful.
Thanks..
The easiest way to do this is:
<Button>
<Image Source="Resources/_25B2_Triangle__black__up_pointing.ico"/>
</Button>
The important thing to remember is to make sure that your icon file is recognized as a valid Resource by your application. With WPF, there is one more step you need to take versus the old winforms way of doing it.
In your Solution Explorer, expand the 'Resources' folder, then click on the "_25B2_Triangle_black_up_pointing.ico" file. Then press F4 for properties. Make sure that the 'Build Action' property is set to 'Resource'.