【问题标题】:Xamarin forms change SwichCell Text ColorXamarin 表单更改 SwichCell 文本颜色
【发布时间】:2016-07-13 13:45:56
【问题描述】:

是否可以更改 xamarins SwichCell 的文本颜色?

目前我的 SwichCell 中的文本是灰色的,我想将其更改为黑色。

我的 xaml 看起来像这样:

..

<TableView Intent="Data" >
    <TableRoot>;
        <TableSection>
            <SwitchCell Text="Allow Push Notifications"/>
        </TableSection>
        <TableSection>
            <ViewCell>
                <ViewCell.View>
                    <Button Grid.Column="1" Text="Log Out" Clicked="LogOutButtonClick" Margin="-20,-20,-20,-20"/>
            </ViewCell.View>
         </ViewCell>
        </TableSection>
        <TableSection>
            <TextCell Text="Android Version 1.2.1" TextColor="Black"/>
        </TableSection>
    </TableRoot>
</TableView>

关于这个我发现here的唯一一件事但这个例子只适用于IOS,其他提供的解决方案使用TextCell和Swich组合,这不适合我的场景(我认为)

有人链接了关于 Swich here 的 stackoverflow 答案。但它不适用于我的情况,因为我使用的是 SwichCell 并且它没有该答案中列出的属性(它也只有一个 android 版本)

【问题讨论】:

  • 我认为您的选择是使用具有水平方向 StackPanel 的 Viewcell 或具有标签和开关的网格布局,或者修改 SwitchCell 以实现您自己的自定义文本的自定义渲染器颜色。

标签: c# xaml xamarin xamarin.ios xamarin.android


【解决方案1】:

如果 SwitchCell 没有公开 BackgroundColor 属性,您可以将 Switch Control 包装在其自己的 ViewCell 中。

无法确认语法,但类似这样:

 <ViewCell>
    <StackLayout>
       <Switch BackgroundColor="Black"/>
     </StackLayout>
 </ViewCell>

【讨论】:

    猜你喜欢
    • 2022-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-09
    相关资源
    最近更新 更多