Dar*_*ter 0 xaml xamarin.forms
将参数添加到 Xamarin Forms 中按钮的 Clicked 事件的最佳方法是什么?对于下面的按钮,我想将按钮文本作为参数发送到代码隐藏中的 SetPinNo
<Button BackgroundColor="Teal" Grid.Row="0" Grid.Column="0" BorderColor="White" BorderRadius="1" TextColor="White" Text="1" Clicked="SetPinNo"/>
Run Code Online (Sandbox Code Playgroud)
如果您不想使用命令,事件处理程序有一个object sender参数。将其投射到按钮上,您就可以提取文本。
var button = (Button)sender;
var text = button.Text;
Run Code Online (Sandbox Code Playgroud)