WPF DataGrid 风格-Silverlight DataGrid?

发布于 2024-08-11 15:24:15 字数 404 浏览 9 评论 0原文

这不是什么秘密:Silverlight 的 DataGrid 默认样式很漂亮,而 WPF 的默认样式很差。

我不想重新发明轮子,而是询问社区是否有人复制了 SL 样式以在 WPF 中使用。

请看一下屏幕截图并自行判断 Silverlight 和 WPF 团队如何投资他们的产品。

Silverlight 默认样式 DataGrid:

Silverlight DataGrid

WPF 默认样式 DataGrid(在 Saied K 的回答后更新):
WPF DataGrid

That's not a secret: Silverlight's DataGrid default style is beautiful while WPF's is poor.

Instead of reinventing the wheel let me ask the community if anyone has copied the SL styles to use in WPF.

Please take a look at the screenshots and judge for yourself how the Silverlight and WPF teams invest in their products.

Silverlight default-style DataGrid:

Silverlight DataGrid

WPF default-style DataGrid (updated after Saied K's answer):
WPF DataGrid

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

ゃ人海孤独症 2024-08-18 15:24:15

我还没有找到任何具有有效 Silverlight 风格 DataGrid 的项目,因此我在 Codeplex 上创建了一个:

http://datagridthemesfromsl.codeplex.com

没有所有主题,但至少有一些。

I haven't found any projects with a working Silverlight-style DataGrid, so I created one on Codeplex:

http://datagridthemesfromsl.codeplex.com

Doesn't have all the themes, but there's at least a few there.

简单 2024-08-18 15:24:15

在 MSDN 的深处,我发现了这个

在文章底部,您将看到以下短语:

例如,请看一下下图,其中显示了使用 ControlTemplates 进行样式设置示例的一部分

如果您单击“使用 ControlTemplates 进行样式设置示例”,它会显示将带您前往下载链接。下载后,您可以编译该项目,它包含各种样式,包括难以捉摸的数据网格样式!您可以获取 MS 的 DataGrid.xaml 文件并根据您的需要进行修改。

Buried deep within MSDN, I found this.

Toward the bottom of the article, you will see this phrase:

For example, take a look at the following illustration that shows part of the Styling with ControlTemplates Sample

If you click 'Styling with ControlTemplates Sample', it will take you to a download link. After download, you can compile the project and it includes all kinds of styles, including the elusive datagrid style! You can take MS's DataGrid.xaml file and modify it for your needs.

好像没有开箱即用的风格。
我向 Microsoft 建议网站发布了一条建议,请在此处此处投票。 gl/S8ekJ" rel="nofollow noreferrer">这里!!!

任何模仿 Silverlight DataGrid 默认样式到 WPF 的人都应该发布他的答案,我会将其标记为答案并给他投票!

多谢!

Seems there is not out-the-box style.
I posted a suggestion to Microsoft suggestions site, please vote here and here!!!

Anyone who has mimicked the Silverlight DataGrid default style to WPF should please post his answer and I will mark it as answer and give him a vote!

Thanks a lot!

如痴如狂 2024-08-18 15:24:15

WPF 附带多种样式,例如 Luna、Aero、Classic 等。这些主题根据您的系统设置进行应用。上一篇文章的屏幕截图看起来像 WPF Classic 主题,但我猜您正在寻找更具吸引力的主题。

例如,如果您在操作系统上使用 Classic 系统主题,但希望 WPF 应用程序使用 Aero 主题,则可以向应用程序添加合并字典并强制使用 Aero 主题,如下所示。请注意,您可能需要相应地更改二进制版本和公钥。

<Application.Resources>
   <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
         <ResourceDictionary
             Source="/PresentationFramework.Aero;V4.0.0.0;31bf3856ad364e35;component\themes/aero.normalcolor.xaml"/>
      </ResourceDictionary.MergedDictionaries>
   </ResourceDictionary>
</Application.Resources>

希望有帮助,
赛义德·K.

WPF ships with a number of styles such as Luna, Aero, Classic, etc. These themes are applied based on your system settings. The screenshot from the previous post looks like the WPF Classic theme, but I'm guessing you're looking for a more appealing theme.

If you’re using a Classic system theme on your OS but would like your WPF application to use the Aero theme for example, you can add a merged dictionary to your app and force the Aero theme as shown below. Please note that you may need to change the binary version and public key accordingly.

<Application.Resources>
   <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
         <ResourceDictionary
             Source="/PresentationFramework.Aero;V4.0.0.0;31bf3856ad364e35;component\themes/aero.normalcolor.xaml"/>
      </ResourceDictionary.MergedDictionaries>
   </ResourceDictionary>
</Application.Resources>

Hope that helps,
Saied K.

ゃ人海孤独症 2024-08-18 15:24:15

我也投票支持了两个连接站点错误,默认情况下这确实应该正确遵循系统主题!

然而与此同时,我发现了一篇有用的帖子 Malav Dhalgara 其中包括以下示例,可用于为 WPFToolkit 中的控件启用 Aero 主题。假设从 Shimmy 发布这个问题之日起,这个示例不是来自 .NET 4.0 中的 DataGrid,但我可能是错的,也许它来自 beta 或 RC 之一。无论如何,这里为使用 WPFToolkit 的用户提供了一个示例解决方法。

        <ResourceDictionary >
            <ResourceDictionary.MergedDictionaries>

                <!--Enable Aero Theme-->
                <ResourceDictionary source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,
                                             PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;
                                             component/themes/aero.normalcolor.xaml" />

                <ResourceDictionary xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
                                             xmlns:sys="clr-namespace:System;assembly=mscorlib">

                    <!--Enable aero theme on toolkit components-->
                    <sys:String x:Key="{ComponentResourceKey 
                                                 TypeInTargetAssembly={x:Type tk:Calendar},ResourceId=Theme}">
                                                 Aero.NormalColor</sys:String>

                    <sys:String x:Key="{ComponentResourceKey
                                                 TypeInTargetAssembly={x:Type tk:DataGrid},ResourceId=Theme}">
                                                 Aero.NormalColor</sys:String>

                    <sys:String x:Key="{ComponentResourceKey
                                                 TypeInTargetAssembly={x:Type tk:DatePicker},ResourceId=Theme}">
                                                 Aero.NormalColor</sys:String>

               </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

I voted for both of the connect site bugs too, this really should follow the system theme properly by default!

However in the mean time I found a useful post by Malav Dhalgara which includes the following example that can be used to enable Aero theme's for controls in the WPFToolkit. Assuming from the date that Shimmy posted this question that this example wasn't comming from the DataGrid in .NET 4.0 but I could be wrong and maybe it was from one of the beta's or RCs. Anyway here is one example workaround for those using the WPFToolkit.

        <ResourceDictionary >
            <ResourceDictionary.MergedDictionaries>

                <!--Enable Aero Theme-->
                <ResourceDictionary source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,
                                             PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;
                                             component/themes/aero.normalcolor.xaml" />

                <ResourceDictionary xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
                                             xmlns:sys="clr-namespace:System;assembly=mscorlib">

                    <!--Enable aero theme on toolkit components-->
                    <sys:String x:Key="{ComponentResourceKey 
                                                 TypeInTargetAssembly={x:Type tk:Calendar},ResourceId=Theme}">
                                                 Aero.NormalColor</sys:String>

                    <sys:String x:Key="{ComponentResourceKey
                                                 TypeInTargetAssembly={x:Type tk:DataGrid},ResourceId=Theme}">
                                                 Aero.NormalColor</sys:String>

                    <sys:String x:Key="{ComponentResourceKey
                                                 TypeInTargetAssembly={x:Type tk:DatePicker},ResourceId=Theme}">
                                                 Aero.NormalColor</sys:String>

               </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文