1

ListViewItem のデータ テンプレート用の BookItemView クラスがあります。

    /// <summary>
    /// Represent a class to keep every items view.
    /// </summary>
    public class BookItemView : ICloneable
    {
        /// <summary>
        /// Create a new instance of BookItemView.
        /// </summary>
        public BookItemView()
        {
            this.ID = Guid.NewGuid();
        }

        /// <summary>
        /// Gets current instance unique id.
        /// </summary>
        public Guid ID
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets or sets items title.
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets items subtitle.
        /// </summary>
        public string Subtitle { get; set; }

        /// <summary>
        /// Gets or sets items description.
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets items icon.
        /// </summary>
        public ImageSource Icon { get; set; }

        /// <summary>
        /// Gets or sets a value which indicate is item marked or not.
        /// </summary>
        public bool Marked { get; set; }

        /// <summary>
        /// Gets or sets a list of BookItemView.
        /// </summary>
        public ObservableCollection<BookItemView> BookItems { get; set; }

        /// <summary>
        /// Create a shallow copy of current object.
        /// </summary>
        /// <returns>A shallow copy of current object.</returns>
        public object Clone()
        {
            return base.MemberwiseClone();
        }
    }

ListView の一部の ListViewItems に特別な背景色を設定するにはどうすればよいですか?

4

2 に答える 2

1

ItemContainerStyleあなたの友達です。例えば:

<ListView>
    <ListView.ItemContainerStyle>
        <Setter Property="Background" Value="{Binding Marked, Converter={StaticResource MarkedConverter}}"/>
    </ListView.ItemContainerStyle>
</ListView>
于 2010-07-20T07:04:27.900 に答える
1

背景を変更する目的のプロパティを定義し、ListViewItem に対して定義された DataTemplate で、プロパティの特定の値で背景を変更します。

于 2010-07-20T07:05:01.370 に答える