홈>
계산기 스타일 그리드가 있습니다. 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 업데이트 레코드 버튼이 정보를 다른 페이지로 전달하지 않음
관련 질문
- c# : 쉘 TabBedPage 앱에서 아이콘 및 텍스트 크기를 변경하는 방법, Xamarin 양식
- Xamarin : 다른 활동간에 페이지 탐색 중 프로그래밍 방식으로 생성 된 레이아웃이 끊어졌습니다.
- c# : Xamarin Forms Image AsportFill이 올바르게 작동하지 않습니다
- 인앱 결제를 사용할 때 Xamarin.Forms 플랫폼 간 구독을 사용하는 방법은 무엇입니까?
- Xamarin Forms에 대한 올바른 이미지 차원 설정
- xamarin : 태국 문화 날짜 레이블이 일치하지 않습니다.
- DatePicker가 버그가 있는 것 같습니다. Xamarin.Forms
- c# : Xamarin.Forms에서 스크롤 막대의 색 변경
- 다른 페이지로 이동하려면 버튼을 얻으려면 어떻게합니까?
- 수신하는 특정 알림 상태에 따라 Xamarin 애플리케이션의 앱 아이콘을 변경하는 것이 얼마나 실현 가능한가
이 구문을 사용하여 제어의 속성을 얻으십시오"{x : Reference myButton}" 완전한 버튼 객체를 얻기 위해 자체 버튼 참조를 보낼 수 있습니다
스타일
XAML
각 버튼의 버튼 이름을 정의하고 해당 버튼의 객체 참조를 가져옵니다.
와이즈 비즈<Button x:Name="myButton" Style="{StaticResource PhoneKeys}" CommandParameter="{x:Reference myButton}" Text="#" Grid.Row="4" Grid.Column="2" />