如何将ToolBar复选框的样式应用于常规复选框? [英] How can I apply the style of a ToolBar CheckBox to a regular CheckBox?

查看:188
本文介绍了如何将ToolBar复选框的样式应用于常规复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个常规的复选框,使它看起来像 CheckBox 里面工具栏

I would like to style a regular CheckBox so it looks like a CheckBox inside a Toolbar:

<StackPanel Orientation="Horizontal">
  <CheckBox Style="{What to put here?}">
    <Image Source="someImage.png" Stretch="None" />
  </CheckBox>
</StackPanel>

有办法获得 Style 使用 ToolBar 并将其绑定?

Is there a way to obtain a reference to the Style use by the ToolBar and 'bind' to it?

EDIT :这是因为我想要一些简单的按钮来控制一些元素的 Visibility ,我不想使用 ToolBar 只是为了这个。

EDIT: The reason for this is because I want a few simple buttons to control the Visibility of some elements and I don't want to use a ToolBar just for this.

推荐答案

没关系,我找到了解决方案:

Never mind, I found the solution:

<StackPanel Orientation="Horizontal">
  <CheckBox Style="{StaticResource {x:Static ToolBar.CheckBoxStyleKey}}">
    <Image Source="someImage.png" Stretch="None" />
  </CheckBox>
</StackPanel>

这篇关于如何将ToolBar复选框的样式应用于常规复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆