相关疑难解决方法(0)

WPF的Windows 7主题?

是否有任何方法可以使WPF应用看起来像在Windows 7上运行,即使它在XP上运行?我正在寻找一些我可以粘贴的主题.我知道Codeplex上的主题项目(http://www.codeplex.com/wpfthemes),但它缺乏支持DataGrid,这是我批判性的需要.我想也许Windows 7主题可能只是一个简单的端口,或者已存在于某个文件中.您所拥有的任何信息(即使是坏消息)都将非常感激.

更新

使用@Lars Truijens的想法,我能够获得主要控件的Windows 7外观,但遗憾的是它不能用于DataGrid我需要的WPF Toolkit 控件.

DataGrid Aero主题看起来像这样

Windows XP外观DataGrid

DataGrid 应该是这样的

Windows 7外观DataGrid

所以,如果有人有任何想法,我仍然在寻找这个问题的解决方案.也许有人为Aero主题构建了一个扩展,涵盖了WPF工具包控件?同样,非常感谢您提供的任何信息.

更新2 - 问题解决了!

要使Aero主题与WPF Toolkit控件一起使用,您只需添加第二个Aero字典,因此您的App.xaml现在应该如下所示.

<Application.Resources>
    ...
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary
                Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" />
            <ResourceDictionary
                Source="pack://application:,,,/WPFToolkit;component/Themes/Aero.NormalColor.xaml" />
            ...
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

另外,我建议你在DataGrid控件中关闭网格线(因为它们看起来很糟糕):

<DataGrid GridLinesVisibility="None" ...>
Run Code Online (Sandbox Code Playgroud)

.net windows wpf themes wpftoolkit

41
推荐指数
1
解决办法
4万
查看次数

如何使用Button,Extender和ListBox制作一个"SelectButton"以获得所需的宽度?

我正在尝试使用SelectButton(https://gist.github.com/loraderon/580405),但我需要为它指定MinWidth.否则宽度只是Extender的宽度.删除ColumnSpan或设置第一列自动不是诀窍.我真的希望它总是具有list + extender符号中最宽元素的宽度.

<UserControl x:Class="loraderon.Controls.SelectButton"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:my="clr-namespace:loraderon.Controls"
         mc:Ignorable="d" 
         SizeChanged="UserControl_SizeChanged"
         d:DesignHeight="30" d:DesignWidth="100">
<Grid
    x:Name="SplitGrid"
    >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="23" />
    </Grid.ColumnDefinitions>
    <Button
        x:Name="Button"
        Click="Button_Click"
        Grid.ColumnSpan="2"
        Padding="0"
        HorizontalContentAlignment="Left"
        >
        <ContentControl
            x:Name="ButtonContent"
            HorizontalContentAlignment="Center"
            ContentTemplate="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:SelectButton}}, Path=ItemTemplate}"
            />
    </Button>
    <Expander
        x:Name="Expander"
        Expanded="Expander_Expanded"
        Collapsed="Expander_Collapsed"
        Grid.Column="1"
        VerticalAlignment="Center"
        IsExpanded="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:SelectButton}}, Path=IsExpanded}"
        />  
    <Popup
        IsOpen="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:SelectButton}}, Path=IsExpanded}"
        PlacementTarget="{Binding ElementName=Button}"
        PopupAnimation="Fade"
        StaysOpen="False"
        >
        <ListBox
            x:Name="ListBox"
            SelectionMode="Single"
            SelectionChanged="ListBox_SelectionChanged"
            SelectedIndex="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:SelectButton}}, Path=SelectedIndex, …
Run Code Online (Sandbox Code Playgroud)

wpf xaml

6
推荐指数
1
解决办法
291
查看次数

复选框的默认ControlTemplate

我找不到默认的WPF ControlTemplateCheckBox。有谁知道如何找到它?我只能找到MSDN上SilverLight默认复选框模板

MSDN为WPF复选框示例提供了一个自定义控件模板,该模板使用X代替复选标记。我专门在寻找WPF随附的默认检查标记样式 -我只是无法为其找到XAML。

我也尝试过使用模板XamlWriter,但无济于事从WPF控制模板示例中下载“简单样式”模板也仅使用X代替经典的复选标记。

wpf xaml styles wpf-controls controltemplate

4
推荐指数
1
解决办法
7896
查看次数

标签 统计

wpf ×3

xaml ×2

.net ×1

controltemplate ×1

styles ×1

themes ×1

windows ×1

wpf-controls ×1

wpftoolkit ×1