like as microsoft document you set static string for value in CascadingValue
Blazor learning path
But I couldn't do this, and in Visual Studio 2022 and .NET6, I have a syntax error.
Thats because razor syntax is searching a variable called Throwback Thursday.
Try using
<CascadingValue Name="DealName" Value=#("Throwback Thursday")>
</CascadingValue>
This markup will take string value
Related
I am trying to set a C# variable (string) to be compiled during the call to msbuild using the "/p" argument:
msbuild.exe mysolution.sln -p:MyCustomProperty=MyCustomValue
However, I'm stuck on how to access this "MyCustomProperty" value (MyCustomValue) in C# code... I was hoping for something simple like using an Attribute like this:
[GetAProjectPropertyAttribute("MyCustomProperty")]
public string MyVariable = "";
But I don't know if such an attribute exists? Are C# project properties not accessible during the compile to set certain code statements?
Any help is appreciated!
Am I doing something wrong or is this the same bug that was reported in 2008?
In the XAML snippet below I am using a custom markup extension:
<Image Source="{wpfx:IconEx Fill={StaticResource mybrush},
Icon={StaticResource myicongeometry}}" />
wpfx is a prefix for my CLR Namespace that I imported in XAML.
IconEx is my custom public Markup Extension class that derives from MarkupExtension.
The image element is rendered correctly in the designer (that is the markup extension does its job), however when I try to build it in either VS 2015 or VS 2017 RC, I get this:
Error: Unknown property 'Fill' for type 'MS.Internal.Markup.MarkupExtensionParser+UnknownMarkupExtension' encountered while parsing a Markup Extension.
Note that the property Fill is public on my markup extension class, as is the class itself. If I change the values of both Fill and Icon properties to not use { } nested markup extension syntax, everything works. The problem is though that I cannot do that.
So, given that it's almost 2017 now, are there any workarounds that do not use the nested property syntax, as it looks like an overkill? Or did I do something wrong, and it;'s not a bug? Maybe I miss some attributes on my markup extension class or it's properties.
#helper GetString()
{
#string.Format("string_{0}","foo");
}
Above code will not compile in ASP.NET MVC 4.0 with Razor 2.0. But if I remove '#' before string.Format, then the code compiles, but the string will not be outputed to the generated HTML. Why's this? In MVC 3.0 with Razor 1.x, above code works as expected. I walkaround this with below code by introducing a variable
#helper GetString()
{
var url = string.Format("string_{0}","foo");
#url
}
Why is this?
#helper GetString()
{
#string.Format("string_{0}","foo");
}
Above code will not compile in ASP.NET MVC 4.0 with Razor 2.0.
That is because the razor engine will see that you have a construct (e.g. string in your example) and you are using the # redundantly. That won't compile as you experienced it.
But if I remove '#' before string.Format, then the code compiles, but
the string will not be outputed to the generated HTML.
Nothing will be outputted because you have not told the razor engine what to write. You just did some code. It is similar to doing in c# and doing a string.Format and not assigning it to a variable.
I walkaround this with below code by introducing a variable
In connection to what I've mentioned earlier, the minute you introduced a variable and wrote it, you are now telling the razor engine to output something. That is similar to a c# console app, wherein:
you did a string.Format: string.Format("string_{0}","foo");
assign its output to a variable: var url = string.Format("string_{0}","foo");
printed the variable: #url
You can read this blog post to better understand how the razor engine works with regards to the usage of #.
Now for an alternative to what you are doing, you can do this:
#helper GetString()
{
<text>#string.Format("string_{0}", "foo")</text>
}
I am building a customizable setup application with WiX, having started with this tutorial:
http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/
The setup needs to be customizable, so I need to set some Variables from inside my MainViewModel this is an example:
var customProductName = "The Custom Product";
this.Bootstrapper.Engine.StringVariables["WixBundleName"] = theCustomProduct;
This works how expected. However, I cannot set the Variable WixBundleManufacturer. I get a System.ArgumentException: Value does not fall within the expected range.
Is it somehow possible to set the manufacturer value from inside my view model at runtime?
No, the WixBundleManufacturer is read-only variable set from the authored Bundle element Manufacturer attribute. You could open a feature request.
The feature request was implemented in v3.10.0.1719. The variable is now writable like any other Burn variable.
According to Microsoft's documentation:
The Windows SharePoint Services 3.0
object model supports updating file
metadata. You can use an indexer on
this property to set a value. For
example, to set the value of the
MyDate property for a given file to
the current date and time, use the
indexer and call the Update method, as
follows:
[Visual Basic]
oFile("MyDate") = DateTime.Now
oFile.Update()
[C#]
oFile["MyDate"] = DateTime.Now;
oFile.Update();
But when I write the line of code:
oFile["Test"] = "test";
It errors out with:
Cannot apply indexing with [] to an
expression of type
'Microsoft.SharePoint.SPFile'
Am I doing something wrong or did Microsoft screw up?
I don't have SharePoint to try it on right now, but it looks like sample is wrong. I believe it should be oFile.Properties["Test"]="test"; as the article talks about Properties property.