windows-phonehereと遭遇したのと同じように、Switch
のコントロールの横のテキストをxamarin-formsに変更すると、Android用の可能性があるようです。違いは、コントロールのテキストをuwpに変更しようとしていることです(前の人が質問してから1年以上経過しています)。XamarinフォームのテキストをUWPで
誰にもこれに対応する(比較的簡単な)ソリューションがありますか、またはthis answerは依然として最良のソリューションですか?
windows-phonehereと遭遇したのと同じように、Switch
のコントロールの横のテキストをxamarin-formsに変更すると、Android用の可能性があるようです。違いは、コントロールのテキストをuwpに変更しようとしていることです(前の人が質問してから1年以上経過しています)。XamarinフォームのテキストをUWPで
誰にもこれに対応する(比較的簡単な)ソリューションがありますか、またはthis answerは依然として最良のソリューションですか?
誰もが、私はXamarin.formsは、ソースコードを切り替えて確認し、この
ための(比較的容易な)解決策を持っています、WinRTのプラットフォームのために、スイッチコントロールのスタイルは、実際にWindows.UI.Xaml.Controls.ToggleSwitch
のスタイルに従っています。
私たちは私たちの要件に基づいてデフォルトテンプレートを変更することができます。デフォルトToggleSwitch
スタイルやテンプレートの場合
は、here
を参照してください。この部分を注意してください:
<ContentPresenter x:Name="OffContentPresenter"
Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="2"
Opacity="0"
Foreground="{TemplateBinding Foreground}"
IsHitTestVisible="False"
Content="{TemplateBinding OffContent}"
ContentTemplate="{TemplateBinding OffContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw" />
<ContentPresenter x:Name="OnContentPresenter"
Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="2"
Opacity="0"
Foreground="{TemplateBinding Foreground}"
IsHitTestVisible="False"
Content="{TemplateBinding OnContent}"
ContentTemplate="{TemplateBinding OnContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw" />
我々は親指を切り替えるに次のテキストを変更する必要がある場合は、我々だけでContent
プロパティを設定しないようにすることができますTemplateBinding
を使用してください。
Application.Resourcesノード(App.xaml)の下にデフォルトのスタイルを追加します。
<x:String x:Key="MyOffContent">Close</x:String>
<x:String x:Key="MyOnContent">Open</x:String>
変更テンプレート:
<ContentPresenter x:Name="OffContentPresenter"
Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="2"
Opacity="0"
Foreground="{TemplateBinding Foreground}"
IsHitTestVisible="False"
Content="{StaticResource MyOffContent}"
ContentTemplate="{TemplateBinding OffContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw" />
<ContentPresenter x:Name="OnContentPresenter"
Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="2"
Opacity="0"
Foreground="{TemplateBinding Foreground}"
IsHitTestVisible="False"
Content="{StaticResource MyOnContent}"
ContentTemplate="{TemplateBinding OnContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw" />
をあなたはこれで慣れていない場合は、ResourceDictionary and XAML resource references
はあなたが必要な場合は、背後にあるコードから値を変更し、2つのリソースの作成を参照してくださいサンプルXAMLコード:http://codepaste.net/qjin7c
スクリーンショット:
'CodePaste'リンクの有効期限が切れています。回答にサンプルxamlを貼り付けることはできますか? – user1