如何设计 Silverlight ToggleSwitch 的标签样式?

发布于 2024-11-28 12:59:00 字数 114 浏览 1 评论 0原文

我想要更改 Silverlight ToggleSwitch 的前景色,尽管当我在 ExpressionBlend 中打开对象时,我没有要编辑的对象项。

这是怎么做到的? (无需重建或使用反射器)?

I am wanting to change the foreground colour of a Silverlight ToggleSwitch, although when i open the object in ExpressionBlend i have no object items to edit.

How is this done? (without rebuilding OR using reflector)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖伴 2024-12-05 12:59:00

我不太确定你在 Blend 中做错了什么,但是,如果你在此处查看 ToggleSwitch 的源代码,你可以看到 ToggleSwitch 的模板:

http://silverlight.codeplex.com/SourceControl/changeset/view/61620#1325059

忽略故事板/VisualStateManager,该控件具有以下标记:

<Grid x:Name="SwitchRoot" Background="Transparent" Height="95" Width="136">
    <Grid x:Name="SwitchTrack" Width="88">
    <Grid x:Name="SwitchBottom" Background="{TemplateBinding SwitchForeground}" Height="32">
        <Rectangle
        x:Name="SwitchBackground"
        Fill="{TemplateBinding Background}"
        Width="76"
        Height="20"
        HorizontalAlignment="Center"
        VerticalAlignment="Center">
        <Rectangle.RenderTransform>
            <TranslateTransform x:Name="BackgroundTranslation"/>
        </Rectangle.RenderTransform>
        </Rectangle>
        <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="2">
        <Border BorderBrush="{StaticResource PhoneBackgroundBrush}" BorderThickness="4"/>
        </Border>
    </Grid>
    <Border
        x:Name="SwitchThumb"
        BorderBrush="{StaticResource PhoneBackgroundBrush}"
        BorderThickness="4,0"
        Margin="-4,0"
        Width="28"
        Height="36"
        HorizontalAlignment="Left">
        <Border.RenderTransform>
        <TranslateTransform x:Name="ThumbTranslation"/>
        </Border.RenderTransform>
        <Border
        x:Name="ThumbCenter"
        BorderBrush="{StaticResource PhoneForegroundBrush}"
        BorderThickness="2"
        Background="White"/>
    </Border>
    </Grid>
</Grid>

我建议在其中使用不同的颜色使用资源 PhoneForegroundBrush

I am not quite sure what you are doing wrong in Blend, however, you can see the template for the ToggleSwitch if you look at the sourcecode for ToggleSwitch here:

http://silverlight.codeplex.com/SourceControl/changeset/view/61620#1325059

Ignoring the storyboards / VisualStateManager, the control has the following markup:

<Grid x:Name="SwitchRoot" Background="Transparent" Height="95" Width="136">
    <Grid x:Name="SwitchTrack" Width="88">
    <Grid x:Name="SwitchBottom" Background="{TemplateBinding SwitchForeground}" Height="32">
        <Rectangle
        x:Name="SwitchBackground"
        Fill="{TemplateBinding Background}"
        Width="76"
        Height="20"
        HorizontalAlignment="Center"
        VerticalAlignment="Center">
        <Rectangle.RenderTransform>
            <TranslateTransform x:Name="BackgroundTranslation"/>
        </Rectangle.RenderTransform>
        </Rectangle>
        <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="2">
        <Border BorderBrush="{StaticResource PhoneBackgroundBrush}" BorderThickness="4"/>
        </Border>
    </Grid>
    <Border
        x:Name="SwitchThumb"
        BorderBrush="{StaticResource PhoneBackgroundBrush}"
        BorderThickness="4,0"
        Margin="-4,0"
        Width="28"
        Height="36"
        HorizontalAlignment="Left">
        <Border.RenderTransform>
        <TranslateTransform x:Name="ThumbTranslation"/>
        </Border.RenderTransform>
        <Border
        x:Name="ThumbCenter"
        BorderBrush="{StaticResource PhoneForegroundBrush}"
        BorderThickness="2"
        Background="White"/>
    </Border>
    </Grid>
</Grid>

I would suggest using a different colour where the resource PhoneForegroundBrush is used.

-柠檬树下少年和吉他 2024-12-05 12:59:00

我认为您需要为控件定义一个新的模板,然后根据需要更改样式。

您可以通过右键单击控件并选择“编辑模板”,然后创建编辑副本来完成此操作。这将为您创建一个可以更改的新样式。

I think you will need to define a new Template for the control and then change your style as you see fit.

You can do this by right clicking on your control and select Edit Template and then create your Edit a Copy. This will create a new Style for you that you can change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文