【问题标题】:ExpanderViewer selectionchanged or selectedItem (Windows Phone)ExpanderViewer selectionchanged 或 selectedItem (Windows Phone)
【发布时间】:2012-04-24 11:02:39
【问题描述】:

我正在尝试将 ExpanderViewer 与 Binding 一起使用,我遵循了 tutorial

现在我需要一个在点击 ExpanderViewer 项目之一时触发的事件。这可能吗?

【问题讨论】:

    标签: wpf silverlight windows-phone-7 silverlight-toolkit


    【解决方案1】:

    我正在使用这个:<Controls:ExpanderView Expanded="ExpanderView_Expanded" />

    对于每个项目,您必须在数据模板中添加事件,例如:

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="CustomHeaderTemplate">
                <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
                <TextBlock Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    

    【讨论】:

    • 我希望在您点击其中一个展开的项目时触发一个事件。这些项目会在您展开主要项目时显示。
    • 那里,我扩展了我的答案......你是这个意思吗?
    • 但是有了这个事件处理程序,我怎样才能得到选中项的绑定对象呢?
    • 在事件处理程序中:var someTempVariable = sender as YourViewModel;
    • 这将返回控件本身。我使用 DataContext 来获取数据。感谢您的帮助:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-17
    • 2016-03-05
    相关资源
    最近更新 更多