I have created a empty Blazor page and put on the page a TextBox (textbox0). I setup the Page property mytext to contain the value "init" then I simply try to bind the property mytext to the TextBox Value setting by setting that to ${mytext}.
I receive the error: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
My mistake, I did not change the property type from "dynamic" to "String". Re-tested and all works perfectly. Once again thanks for your quick response.
In continuation of this topic:
I need to pass a boolean value to the dialog to set the read-only property for the textbox.
Dialog call:
protected async System.Threading.Tasks.Task Button0Click(MouseEventArgs args)
{
DialogService.Open($"Editable textbox dialog", new Dictionary<string, object>() { {"IsEnabled", true} });
}
When you specify somewhere in your app that you are going to open a page with parameters Radzen will generate properties in that page to receive the parameters. You can use the property directly without parameters.MyProperty and it should work in both runtime and design time. We will look on how to fix parameters. for the designer.
Better now, thanks!
But there is still a comment:
if you use an enumeration as a parameter, an error appears in the editor. Everything is ok in runtime.
Example:
Add enum in main namespace:
namespace Test.Pages
{
public enum MyEnum
{
Editable,
Readonly,
Special
}
}
Open dialog with:
DialogService.Open("Dialog", new Dictionary<string, object>() { {"DialogType", MyEnum.Readonly} });
Binding readonly property component to parameter:
${parameters.DialogType==MyEnum.Readonly}
Supporting that expression in design time would require knowing the parameter type beforehand (e.g. MyEnum). This however would introduce a big performance penalty as we would have to traverse the whole application.
Using ${Mode==MyEnum.Value} should work both in runtime and design time.
Great! You save my day..
Please explain why a runtime error occurs when binding an ${Mode==MyEnum.Value} expression to the property "disabled" (components like dropdown, datepicker etc)
If these components has binding value then runtime error occurs.
The visibility property binding without problems.
What is the runtime error that you get when using ${Mode==MyEnum.Value}? We can't reproduce any runtime error when binding that expression to the Disabled property of a TextBox.
Please remind me where the Radzen's log file location (MacOS)
Binding to the disabled property of the text box does not cause errors.
An error occurs when binding to this property in dropdown, which has a value property attached
Message from output during complie:
dotnet: obj/Debug/netcoreapp3.1/Razor/Pages/Dialog.razor.g.cs(142,235): error CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type. [/Users/domivan/Documents/Radzen/Test/server/Test.csproj]
Here is a sample application which builds and runs fine - it uses an enum and sets the Disabled property of a dropdown to an expression. Does it work at your side?BlazorEnum.zip (24.5 KB)
Yes, your example works.
But I wrote that the error occurs when the dropdown is tied to the collection and has the value property set
In your example, just an empty dropdown, in which case there will be no error
Ok, here is the updated project.
It has a compilation error.
If you remove the binding to the value property in the dropdown component, there will be no error. RadzenProject