WPF。如何创建具有相同的外观很多列表视图 [英] WPF. How do I create many LIstViews with the same look

查看:125
本文介绍了WPF。如何创建具有相同的外观很多列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我最近的项目定义的列表视图,并意识到,我会用更多的列表视图寻找完全相同的并具有相同solumns。由于我是新来WPF我是好奇,要做到这一点德最佳途径。难道它来创建一个用户控件?使用样式?我试着使用样式,但没有工作,我希望的方式。我试着用的风格,这样设置的查看属性。

I've defined a listview in my recent project and realized that I will be using more listviews looking exactly the same and having the same solumns. Since I'm new to WPF am I curious of teh best way to do this. Is it to create a usercontrol? Use styles? I've tried to use styles but it didnt work the way I was hoping. I tried to set the "View" property using style, like this.

<Style x:Key="ListViewStyle" TargetType="{x:Type ListView}">
    <Setter Property="View">
        <ListView.View>
            <GridView>

但它没有工作,所以我问你的意见?谢谢你。

But it didnt work so I'm asking for your opinion?! Thanks.

推荐答案

您错过了 Setter.Value 标签,并且你不需要 ListView.View 标签:

You're missing the Setter.Value tag, and you don't need the ListView.View tag :

<Style x:Key="ListViewStyle" TargetType="{x:Type ListView}">
    <Setter Property="View">
        <Setter.Value>
            <GridView>

这篇关于WPF。如何创建具有相同的外观很多列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆