且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

结合在Windows Phone应用程序的用户控件的属性

更新时间:2023-12-06 10:49:34

要能够绑定到一个属性,它需要一个的依赖属性。下面是如何title属性需要修改:

To be able to bind to a property, it need to be a dependency property. Here is how the title property need to be modified:

public partial class LongListSelectorItemControl
{


   public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(LongListSelectorItemControl), new PropertyMetadata(default(string), TitlePropertyChanged));

        private static void TitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LongListSelectorItemControl myControl=d as LongListSelectorItemControl;
            myControl.TitleTextBlock.Text = e.NewValue as string;
        }

        public string Title
        {
            get { return (string) GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }
....
}

您需要做同样的事情与LastModifiedDate属性。

You will need to do the same thing with the LastModifiedDate property.