홈>
계산기 스타일 그리드가 있습니다. Xamarin Forms에서 버튼의 텍스트를 명령 매개 변수로 전달하는 방법은 다음과 같습니다.
컨텐츠 리소스
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="PhoneKeys" TargetType="Button">
<Setter Property="BackgroundColor" Value="White"/>
<Setter Property="FontSize" Value="36"/>
<Setter Property="Command" Value="{Binding Source={x:Reference contactsListView}, Path=BindingContext.TapCommand1}"/>
<Setter Property="CommandParameter" Value="Pass Button Text"/>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
그리드 레이아웃
<Button Style="{StaticResource PhoneKeys}" Text="1" Grid.Row="1" Grid.Column="0" />
<Button Style="{StaticResource PhoneKeys}" Text="1" Grid.Row="1" Grid.Column="0" />
<Button Style="{StaticResource PhoneKeys}" Text="2" Grid.Row="1" Grid.Column="1" />
<Button Style="{StaticResource PhoneKeys}" Text="3" Grid.Row="1" Grid.Column="2" />
<Button Style="{StaticResource PhoneKeys}" Text="4" Grid.Row="2" Grid.Column="0" />
<Button Style="{StaticResource PhoneKeys}" Text="5" Grid.Row="2" Grid.Column="1" />
<Button Style="{StaticResource PhoneKeys}" Text="6" Grid.Row="2" Grid.Column="2" />
<Button Style="{StaticResource PhoneKeys}" Text="7" Grid.Row="3" Grid.Column="0" />
<Button Style="{StaticResource PhoneKeys}" Text="8" Grid.Row="3" Grid.Column="1" />
<Button Style="{StaticResource PhoneKeys}" Text="9" Grid.Row="3" Grid.Column="2" />
<Button Style="{StaticResource PhoneKeys}" Text="*" Grid.Row="4" Grid.Column="0" />
<Button Style="{StaticResource PhoneKeys}" Text="0" Grid.Row="4" Grid.Column="1" />
<Button Style="{StaticResource PhoneKeys}" Text="#" Grid.Row="4" Grid.Column="2" />
- 답변 # 1
관련 자료
- swift - Observable 객체에 매개 변수 값 전달
- C ++ 매개 변수 값 복사
- php - 문자열에서 다른 배열의 값을 직접 전달하여 배열 값에 액세스
- reactjs - React의 기능 구성 요소에서 값 전달
- Blazor 'Global' Parameter - blazor 'global'매개 변수 - mainlayoutrazor, navmenurazor, counterrazor 간 전달 :이리저리
- c# - Xamarin에서 Button Click 이벤트 처리기를 사용하여 ID를 매개 변수로 사용하는 새 페이지로 이동하는 방법은 무엇입니까?
- cmd - 10 개 이상의 매개 변수 배치 파일 선택 명령
- python - Tkinter 버튼이 명령을 실행하지 않습니다
- python 3.x - discordpy의 키 값으로 API 응답을 구문 분석하기 위해 clientcommand 매개 변수를 가져올 수 없습니다
- javascript - 리스너 또는 라디오 버튼 값 변경 JQuery v351
- javascript - react js에서 라디오 버튼을 클릭하면 API와 다른 값을 표시하는 방법은 무엇입니까?
- c# - 하나의 방법으로 하나의 양식으로 여러 버튼에 대한 값 가져 오기
- python - 셀레늄을 사용하여 ID, 값 및 유형이없는 요소 (버튼)를 찾는 방법은 무엇입니까?
- javascript - 반응 - setstate 콜백에 값 전달
- javascript - 동적 테이블 셀에서 값 가져 오기 및 해당 값을 JS 함수에 전달
- bash - JSON 속성 값을 바꾸려면 sed 명령이 필요합니다
- c# - 라디오 버튼의 가치를 얻는 방법?
- javascript - 내 DataTable의 버튼이 클릭 할 때마다 전달되어야하는 ID가 아닌 0을 전달하는 이유는 무엇입니까?
- python - Tkinter, for-loop에서 버튼을 클릭하여 값을 가져 오거나 반환하는 방법은 무엇입니까?
- html - PHP 업데이트 레코드 버튼이 정보를 다른 페이지로 전달하지 않음
관련 질문
- Xamarin /c# 탭 페이지 ZXING 스캐너 문제
- xamarin : DisplayAlert 외부에서 클릭하기
- Visual Studio 16.9.0에서 Android "디바이스에 배포"오류-명령이 너무 김
- xamarin 양식에서 어두운 테마를 실제로 비활성화하는 방법은 무엇입니까?
- android : xamarin 또는 네이티브 플랫폼에서 팝 아웃보기를 만드는 방법
- Xamarin 양식 : 유형에 올바른 서명이없는 이벤트 처리기,
- 내 XamarinMediaManager가 HLS를 재생할 수없는 이유는 무엇입니까?
- xamarin : TabBePage를 사용할 때 다른 페이지를 볼 수 없습니다
- 일반 텍스트 트래픽 허용 xamarin 양식
- Xamarin 긴 텍스트 바인딩으로 인해 레이아웃이 잘림
이 구문을 사용하여 제어의 속성을 얻으십시오"{x : Reference myButton}" 완전한 버튼 객체를 얻기 위해 자체 버튼 참조를 보낼 수 있습니다
스타일
XAML
각 버튼의 버튼 이름을 정의하고 해당 버튼의 객체 참조를 가져옵니다.
와이즈 비즈<Button x:Name="myButton" Style="{StaticResource PhoneKeys}" CommandParameter="{x:Reference myButton}" Text="#" Grid.Row="4" Grid.Column="2" />