更改longlistselector中DataTemplate内部控件的可见性

时间:2013-07-02 09:17:20

标签: c# xaml windows-phone-8

longlistselector包含datatemplate imagetext和两个buttons, 现在我想做的是,当我在longlistselector中选择items时,相应的项buttons将可见

1 个答案:

答案 0 :(得分:0)

将您的LongListSelector与Selected item属性绑定,当您的选择被更改时,将调用Property,您可以获取选择的元素,然后更改按钮的可见性...

<ls:LongListSelector Margin="0,10,0,10" ItemsSource="{Binding attractionlist,Mode=TwoWay,UpdateSourceTrigger=Default}" SelectedItem="{Binding SelectedAttractionDetail,Mode=TwoWay,UpdateSourceTrigger=Default}" >

然后制作这样的房产..

            private ObservableCollection<AttractionDetails> _attractionlist;
            public ObservableCollection<AttractionDetails> attractionlist
            {
                get
                {
                    return _attractionlist;
                }
                set
                {
                    _attractionlist = value;
                    RaisePropertyChanged("attractionlist");

                   // Change visibility here
                }
            }