WPF Blazor hybrid - how to use values from .razor in code-behind?

Viewed 27

I have a MainWindow.xaml with a BlazorWebView. I've added two forms in my Index.razor:

<form>
        <input type="text" id="id_item1" name="item1" @bind="@inputValue1" @oninput="OnInputEvent1" ><br>
</form>
<form action="#">
        <select name="categories" id="cat1" size="1">
            <option value="" selected>ThisCategory</option>
</form>

This second form is a drop down menu.

I have been trying to bind it like this:

@code {

    private string inputValue1 = "";
    private void OnInputEvent1(ChangeEventArgs changeEvent) {

        inputValue1 = (string)changeEvent.Value;
    }

It's basically a shopping list. Write in an item in form 1, choose its category in form2.

I then want to grab the item and its correlating category and somehow get it to my SQL database. I don't care if I use it from the index.razor.cs or from the MainWindow code-behind.

How can I go about doing that? (This project is not MVVM)

0 Answers
Related