棒棒牛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 605|回复: 1

[心得] WPF一个选中遮罩的例子 [复制链接]

版主

WPF_1.5_ray

Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

游币
259
金币
586
经验
1690
积分
2179
帖子
429

2011 年度优秀版主 2010 年度优秀版主

发表于 2011-10-11 17:11:14 |显示全部楼层
在群里有人问的效果:

未选中时都是高亮,选中以后,选中的项高亮,其他的被遮罩

未选中.png

选中.png


代码: WpfSelectionMask.zip (20.85 KB, 下载次数: 40)
What is real?

版主

WPF_1.5_ray

Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

游币
259
金币
586
经验
1690
积分
2179
帖子
429

2011 年度优秀版主 2010 年度优秀版主

发表于 2011-10-11 17:11:55 |显示全部楼层
使用时的代码很简单:

    <l:SelectionMaskDecorator>
        <ListBox x:Name="lb_Icons"
                 HorizontalContentAlignment="Stretch"
                 VerticalContentAlignment="Stretch"
                 ItemsSource="{Binding}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel ItemHeight="50" ItemWidth="50" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Rectangle Fill="SkyBlue" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </l:SelectionMaskDecorator>
What is real?
您需要登录后才可以回帖 登录 | 注册

bbniu.com (湘ICP备06008909号)  

GMT+8, 2012-5-21 21:04

Copyright © 2009-2011 bbniu.com. All Rights Reserved.

回顶部