【问题标题】:Is there a way to have different Opacity props between parent and child usercontrols?有没有办法在父子用户控件之间有不同的不透明度道具?
【发布时间】:2012-02-17 22:30:04
【问题描述】:

我有一个滚动视图。 其中有一个 itemsControl。 所以我想将滚动视图的不透明度设置为 50%,但希望对 itemsControl 设置 100% 的不透明度。

现在,如果我将 SV 设置为 50% 的不透明度,那么我对 itemsControl 也有 50% 的不透明度。

有办法吗?

提前致谢。

【问题讨论】:

    标签: wpf properties parent-child opacity


    【解决方案1】:

    您始终可以覆盖 ScrollViewer's Template,因此只有 ScrollBar 部分的不透明度为 50%

    简化的模板如下所示:

    <Grid>
      <Border>
        <ScrollContentPresenter />
      </Border>
    
      <!-- Set Opacity of these only -->
      <ScrollBar x:Name="PART_VerticalScrollBar" />
      <ScrollBar x:Name="PART_HorizontalScrollBar" />
    </Grid>
    

    【讨论】:

      猜你喜欢
      • 2019-07-07
      • 2011-03-12
      • 2011-07-05
      • 1970-01-01
      • 2021-10-16
      • 2015-03-09
      • 2020-09-27
      • 2021-03-01
      • 2018-04-19
      相关资源
      最近更新 更多