title: blazor add parameters to templated component
body: <p>I have a Blazor Popup that takes a template to show his content:</p>
  <p><em>CustomPopup.razor</em></p>
  <pre><code>&lt;Popup
      @bind-Visible=&quot;@CreatePopupVisible&quot;
      HorizontalAlignment=&quot;HorizontalAlignment.Center&quot;
      VerticalAlignment=&quot;VerticalAlignment.Center&quot;
      ShowFooter=&quot;true&quot;
      HeaderText=&quot;@(&quot;Create&quot; + Label)&quot;&gt;
      &lt;BodyTemplate&gt;
          @EditForm
      &lt;/BodyTemplate&gt;
      &lt;FooterContentTemplate&gt;
      &lt;/FooterContentTemplate&gt;
  &lt;/Popup&gt;
  
  @code {
      [Parameter]
      public string? Label { get; set; }
  
      [Parameter]
      public RenderFragment EditForm { get; set; }
  
      bool CreatePopupVisible { get; set; }
  
  }
  </code></pre>
  <p>to this component i pass an EditForm with 2 buttons that takes a function to handle the cancel option:</p>
  <p><em>CustomEditForm.razor</em></p>
  <pre><code>&lt;EditForm Model=&quot;Entity&quot; OnValidSubmit=&quot;@HandleValidSubmit&quot;&gt;
      &lt;DataAnnotationsValidator /&gt;
      &lt;ValidationSummary /&gt;
      &lt;div class=&quot;d-flex flex-column&quot;&gt;
          &lt;InputNumber id=&quot;factory-id&quot; class=&quot;mt-2 mb-2&quot; @bind-Value=&quot;Entity.Id&quot; /&gt;
          &lt;InputText id=&quot;factory-businessname&quot; class=&quot;mt-2 mb-2&quot; @bind-Value=&quot;Entity.BusinessName&quot; /&gt;
          &lt;InputText id=&quot;factory-address&quot; class=&quot;mt-2 mb-2&quot; @bind-Value=&quot;Entity.Address&quot; /&gt;
          &lt;div class=&quot;d-flex flex-row&quot;&gt;
              &lt;button class=&quot;btn btn-primary mt-2 mb-2 flex-grow-1&quot; type=&quot;submit&quot;&gt;Modifica&lt;/button&gt;
              &lt;button @onclick=&quot;HandleCancel&quot; class=&quot;btn btn-secondary mt-2 mb-2 flex-grow-1&quot; type=&quot;submit&quot;&gt;Annulla&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/EditForm&gt;
  
  @code {
  
      [Parameter]
      public Action HandleCancel { get; set; }
      
  
      [Parameter]
      public Factory Entity { get; set; }
      
      private void HandleValidSubmit()
      {
          Logger.LogInformation(&quot;HandleValidSubmit called&quot;);
      }
  }
  </code></pre>
  <p>if i use the EditForm normally like this:</p>
  <p><em>SomeFile.razor</em></p>
  <pre><code>&lt;CustomEditForm HandleCancel=&quot;()=&gt;{}&quot;&gt;
  </code></pre>
  <p>its all good but when i use it in a templated component how can i pass a function to him from inside the CustomPupup.razor file?</p>
  <p>i need to pass a function to set CreatePopupVisible to false when someone clicks on the cancel button</p>
  <p>ty in advance for the help!</p>
  <h1>EDIT</h1>
  <p>ty for the help but i think i provided not enough information to get the right answer, my bad</p>
  <p>so, i want to be able to call the CustomEditForm normally and passing a function defined by the parent to manage the HandleCancel like this:</p>
  <p><em>MainPage.razor</em></p>
  <pre><code>@page ...
  
  &lt;Grid @ref=&quot;Grid&quot;&gt;
  //the grid has a method that closes this CustomEditForm
      &lt;Template&gt;
          &lt;CustomEditForm HandleCancel=&quot;() =&gt; Grid.CancelRowEdit()&quot;/&gt;
      &lt;/Template&gt;
  &lt;/Grid&gt;
  </code></pre>
  <p>but i also want to close the popup using a function defined inside himself like this:</p>
  <p>AnotherPage.razor</p>
  <pre><code>&lt;CustomPopup&gt;
      &lt;EditForm&gt;
          &lt;CustomEditForm Entity=&quot;new Factory()&quot;/&gt;
      &lt;/EditForm&gt;
  &lt;/CustomPopup&gt;
  </code></pre>
  <p>in this case the edit form should handle the cancel by calling a CustomPopup defined method</p>