I have a button defined as a resource within a ControlTemplate in order to be able to use it more than once.
<Grid.Resources>
<ControlTemplate x:Key="GenericButton">
<Button Text="Click Here"
IsEnabled="{Binding SelectedItemProperty,
Converter={StaticResource IsNotNullConverter}}" />
</ControlTemplate>
</Grid.Resources>
I would like the button to be a little more dynamic and receive the SelectedItemProperty name as a parameter instead.
Currently, I’m displaying the resource button in this fashion (which works fine as long as the SelectedItemProperty name is concretely spelled out as seen in the above code):
<VerticalStackLayout Padding="20" Spacing="20" VerticalOptions="Fill">
<ContentView ControlTemplate="{StaticResource GenericButton}" />
</VerticalStackLayout>
Instead, I would like to do something like this:
<ContentView ControlTemplate="{StaticResource GenericButton, Parameter=SelectedItemProperty}" />
And the resource button would look something like this:
<ControlTemplate x:Key="GenericButton">
<Button Text="Click Here"
IsEnabled="{Binding PassedParameter,
Converter={StaticResource IsNotNullConverter}}" />
</ControlTemplate>
What is that concept of passing a parameter between Controls called? And how to approach this problem?