首页 新闻 会员 周边 捐助

WPF XAML 头像变灰效果

2
悬赏园豆:100 [已关闭问题] 关闭于 2011-12-09 10:28

给你一个集合,集合中每项都有两个字段用户头像地址(string)和在线状态(bool)

要求在Listbox中直接用绑定实现,大虾们帮帮忙呀

下面是我自己写的(但有问题):

   <Image Width="50"    x:Name="img"  >
                                <Image.Resources>

 <BitmapImage x:Key="OnLine"  DecodePixelWidth="200" UriSource="{Binding HeadPic, Converter={StaticResource BitMapImgUriConvert}}"></BitmapImage>
                                    <FormatConvertedBitmap x:Key="OffLine" Source="{StaticResource OnLine}"  DestinationFormat="Gray32Float"/>
                                </Image.Resources>
                                <Image.Style>
                                    <Style  TargetType="Image">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding State}" Value="True">
                                                <Setter Property="Source" Value="{StaticResource OnLine}"></Setter>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding State}" Value="False">
                                                <Setter Property="Source" Value="{StaticResource OffLine}"></Setter>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>

Luffy Huang的主页 Luffy Huang | 初学一级 | 园豆:25
提问于:2011-06-10 17:15
< >
分享
所有回答(1)
0

可以的,你要保证Binding地方写正确

黄泉天上来 | 园豆:230 (菜鸟二级) | 2011-06-30 13:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册