更改日历项目的前景色

2024-01-13

我正在 WPF 中自定义日历控件,并且可以调整背景颜色、标题前景色等。但我找不到如何编辑 1-31 天日历项目的外观。在

截屏:

正如您所看到的,这些数字都是深灰色的,几乎不可读。我还想去掉鼠标悬停时的蓝色覆盖层。

Code:

<Window x:Class="WPFDatePickerSample.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window2" Height="500" Width="500"
    Background="#2F2F2F">

<Window.Resources>
    <Style TargetType="{x:Type CalendarItem}">
        <Setter Property="Margin" Value="50"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarItem}">
                    <ControlTemplate.Resources>
                        <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
                            <TextBlock Foreground="#FFA9C822" FontWeight="Normal" FontSize="12" HorizontalAlignment="Center" Margin="0,5,0,5" Text="{Binding}" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </ControlTemplate.Resources>

                    <Grid x:Name="PART_Root">
                        <Grid.Resources>
                            <SolidColorBrush x:Key="DisabledColor" Color="#A5FFFFFF"/>
                        </Grid.Resources>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_DisabledVisual"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1">
                            <Border BorderBrush="#FFFFFFFF" BorderThickness="0" CornerRadius="0">
                                <Grid>
                                    <Grid.Resources>
                                        <ControlTemplate x:Key="PreviousButtonTemplate" TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal"/>
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <ColorAnimation Duration="0" To="#FFA9C822" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>

                                                <Rectangle Fill="Transparent" Opacity="1" Stretch="Fill"/>

                                                <Grid>
                                                    <Path x:Name="path" Data="M288.75,232.25 L288.75,240.625 L283,236.625 z" Fill="Silver" HorizontalAlignment="Left" Height="10" Margin="5,-6,0,0" Stretch="Fill" VerticalAlignment="Center" Width="6"/>
                                                </Grid>
                                            </Grid>
                                        </ControlTemplate>

                                        <ControlTemplate x:Key="NextButtonTemplate" TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal"/>
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <ColorAnimation Duration="0" To="#FFA9C822" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path"/>
                                                            </Storyboard>
                                                        </VisualState>

                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>

                                                <Rectangle Fill="Transparent" Opacity="1" Stretch="Fill"/>

                                                <Grid>
                                                    <Path x:Name="path" Data="M282.875,231.875 L282.875,240.375 L288.625,236 z" Fill="Silver" HorizontalAlignment="Right" Height="10" Margin="0,-6,5,0" Stretch="Fill" VerticalAlignment="Center" Width="6"/>
                                                </Grid>
                                            </Grid>
                                        </ControlTemplate>

                                        <ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal"/>
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To=".7" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="buttonContent"/>
                                                            </Storyboard>
                                                        </VisualState>

                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="buttonContent"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>

                                                <ContentPresenter x:Name="buttonContent" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" TextElement.Foreground="Silver" TextElement.FontFamily="Segoe UI" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,3,1,9" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Grid.Resources>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>

                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>

                                    <Grid Grid.Row="0" Grid.ColumnSpan="4" Background="#3C3C3C" HorizontalAlignment="Stretch">
                                        <Button x:Name="PART_PreviousButton" Grid.Column="0" Focusable="False" HorizontalAlignment="Left" Height="20" Grid.Row="0" Template="{StaticResource PreviousButtonTemplate}" Width="28"/>
                                        <Button x:Name="PART_HeaderButton" Grid.Column="1" FontWeight="Normal" Focusable="False" FontSize="13" HorizontalAlignment="Center" Grid.Row="0" Template="{StaticResource HeaderButtonTemplate}" VerticalAlignment="Center" />
                                        <Button x:Name="PART_NextButton" Grid.Column="2" Focusable="False" HorizontalAlignment="Right" Height="20" Grid.Row="0" Template="{StaticResource NextButtonTemplate}" Width="28"/>
                                    </Grid>
                                    <Grid x:Name="PART_MonthView" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="6,-1,6,6" Grid.Row="1" Visibility="Visible">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>

                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                    </Grid>

                                    <Grid x:Name="PART_YearView" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="6,-3,7,6" Grid.Row="1" Visibility="Hidden">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>

                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                    </Grid>
                                </Grid>
                            </Border>
                        </Border>

                        <Rectangle x:Name="PART_DisabledVisual" Fill="{StaticResource DisabledColor}" Opacity="0" RadiusY="2" RadiusX="2" Stretch="Fill" Stroke="{StaticResource DisabledColor}" StrokeThickness="1" Visibility="Collapsed"/>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Visibility" TargetName="PART_DisabledVisual" Value="Visible" />
                        </Trigger>

                        <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year">
                            <Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
                            <Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade">
                            <Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
                            <Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Calendar}">
        <Setter Property="Background" Value="#3C3C3C"/>

        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Calendar}">
                    <StackPanel x:Name="PART_Root" HorizontalAlignment="Center">
                        <CalendarItem x:Name="PART_CalendarItem" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>

<Grid>
    <Calendar Width="400" Height="400"></Calendar>
</Grid>

虽然这是一个几年前的问题,但我现在只需要设计一个日历。我的应用程序用于触摸屏应用程序,无法使用普通日历。所以我在查看了你的问题和 Sheridan 的答案并浏览了 MSDN 之后日历日按钮样式 https://msdn.microsoft.com/en-us/library/cc278077(v=vs.95).aspx我完成了我的工作,所以这是任何感兴趣的人的结果,这是我基于你的触摸日历。

这就是风格:

<Style x:Key="CalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
    <!--<Setter Property="Background" Value="#FFBADDE9" />-->

    <Setter Property="FontSize" Value="20" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="MinWidth" Value="35" />
    <Setter Property="MinHeight" Value="35" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="CalendarDayButton">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To=".5" Duration="0" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To=".5" Duration="0" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                    <DoubleAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To=".35" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="SelectionStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Unselected" />
                            <VisualState x:Name="Selected">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity" To=".75" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="CalendarButtonFocusStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="CalendarButtonFocused">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility" Duration="0">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="CalendarButtonUnfocused">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility" Duration="0">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ActiveStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Active" />
                            <VisualState x:Name="Inactive">
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="(ContentControl.Foreground).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="{DynamicResource DisableDay1}" Duration="0" />
                                    <ColorAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="(ContentControl.Foreground).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="{DynamicResource DisableDay2}" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="DayStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="RegularDay"  />
                            <VisualState x:Name="Today">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="TodayBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    <DoubleAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="(ContentControl.Foreground).(GradientBrush.GradientStops)[1].(GradientStop.Offset)" To="1" Duration="0" />
                                    <DoubleAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="(ContentControl.Foreground).(GradientBrush.GradientStops)[2].(GradientStop.Offset)" To="1" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="BlackoutDayStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="NormalDay" />
                            <VisualState x:Name="BlackoutDay">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="BlackoutVisual" Storyboard.TargetProperty="Opacity" To=".2" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>

                    <Rectangle x:Name="TodayBackground" RadiusX="1" RadiusY="1" Opacity="0" Fill="#FFAAAAAA" />
                    <Rectangle x:Name="SelectedBackground" RadiusX="1" RadiusY="1" Opacity="0" Fill="{TemplateBinding Background}" />
                    <Rectangle x:Name="Background" RadiusX="1" RadiusY="1" Opacity="0" Fill="{TemplateBinding Background}" />

                    <ContentControl x:Name="Content" IsTabStop="False" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" FontSize="{TemplateBinding FontSize}" Margin="5,1,5,1">
                        <ContentControl.Foreground>
                            <LinearGradientBrush>
                                <GradientStop Offset="0" Color="{DynamicResource SelectedDay1}" />
                                <GradientStop Offset="0" Color="{DynamicResource SelectedDay2}" />
                                <GradientStop Offset="0" Color="{DynamicResource NormalDay1}" />
                                <GradientStop Offset="1" Color="{DynamicResource NormalDay2}" />
                            </LinearGradientBrush>
                        </ContentControl.Foreground>
                    </ContentControl>

                    <Path x:Name="BlackoutVisual" Opacity="0" Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Fill="#FF000000" Stretch="Fill" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" />
                    <Rectangle x:Name="FocusVisual" Visibility="Collapsed" IsHitTestVisible="false" RadiusX="1" RadiusY="1" Stroke="#FF6DBDD1" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

所以你只需要设置资源的颜色:

<Color x:Key="DisableDay1">Black</Color>
<Color x:Key="DisableDay2">Black</Color>

<Color x:Key="NormalDay1">LightGray</Color>
<Color x:Key="NormalDay2">Gray</Color>

<Color x:Key="SelectedDay1">White</Color>
<Color x:Key="SelectedDay2">White</Color>

...并将样式模板添加到您的日历中:

<Style x:Key="TouchCalendarStyle" TargetType="{x:Type Calendar}">    
    <Setter Property="CalendarDayButtonStyle" Value="{DynamicResource CalendarDayButtonStyle}"/>
    ...
</Style>

所以谢谢你的帮助。 :)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

更改日历项目的前景色 的相关文章

  • App 对象中的 Log4Net?

    我正在开始在 WPF 桌面应用程序中进行日志记录 使用 Log4Net 作为日志记录组件 这是我的问题 在一个简单的桌面应用程序中 是否有任何理由不将我的记录器实例化为 App 类 App xaml cs 的属性 就像这样 public p
  • 树视图上下文菜单命令未触发

    我有一个绑定到某些属性类型的 Observable 集合的树视图 有一个 HierarchicalDataTemplate 在树视图中显示数据 现在我需要显示每个 HierarchicalDataTemplate 项目的特定上下文菜单 我使
  • 手动更新目标后,单向绑定停止工作

    我有这样的WPF绑定代码 TestModel source new TestModel TestModel target new TestModel Bind source target BindingMode OneWay source
  • WPF:使用 StringFormat={}{0:F2} 进行文本框绑定。不显示零

    我使用以下 XAML 将对象绑定到 TextBox
  • 如何使用DocumentViewer显示流程文档?

    我的资源中有一个简单的流程文档 FlowDocument1 xaml
  • 如何使用 WPF 从 XML 文件创建树视图?

    这是 XML 文件
  • 不支持 URI 前缀

    我正在尝试使用以下方法加载和播放波形文件 SoundPlayer simpleSound new SoundPlayer pack application MyAssembly component Sounds 10meters wav s
  • 关闭主窗口时 WPF 应用程序不会关闭

    我习惯了在 Visual Studio 中进行 WinForms 编程 但我想尝试一下 WPF 我向我的项目添加了另一个窗口 名为 Window01 主窗口称为MainWindow 之前public MainWindow 构造函数我声明Wi
  • 如何对 Prism / MEF 中的 ItemsControl 中的视图进行排序?

    我使用 prism v4 和 MEF 来加载我的模块 我的模块包含一些视图 MVVM 这些视图由 MEF 自动加载到 ItemsControl NavigationRegion 中 这很好用 所有项目都显示在 ItemControl 中 但
  • OxyPlot WPF 不适用于按钮单击

    我在使用 OxyPlot 时遇到了一些问题 但无法通过他们的文档或其他搜索来解决 我正在开发一个 wpf 应用程序 它允许用户通过按钮单击事件打开 csv 然后执行一些数学运算并报告一些有用的信息 我想绘制一些生成的数据 因此使用 OxyP
  • WPF ListBox - 如何从数据表中放入值?

    I have ListBox并希望将值放入此列表框中DataTable listBoxVisibleFields DataContext SelectedFields Where SelectedFields is a DataTable充
  • 以编程方式使用自定义元素创建网格

    我正在尝试以编程方式创建一个网格 并将自定义控件作为子项附加到网格中 作为 2x2 矩阵中的第 0 行第 0 列 为了让事情变得更棘手 我使用了 MVVM 设计模式 下面是一些代码可以帮助大家理解这个想法 应用程序 xaml cs base
  • 如何创建向后兼容 Windows 7 的缩放和尺寸更改每显示器 DPI 感知应用程序?

    我是 WPF 和 DPI 感知 API 的新手 正在编写一个在 Windows 7 8 1 和 10 中运行的应用程序 我使用具有不同每个显示器 DPI 设置的多个显示器 并且有兴趣将我的应用程序制作为跨桌面配置尽可能兼容 我已经知道可以将
  • 实体框架 - 绑定 WPF 树视图控件

    在服务类别表中 ParentCategoryId 是 ServiceCategoryId 它是父类别 我的类别可以有第 n 级层次结构 因此我需要使用树视图控件来呈现它 我怎样才能做到这一点 Thanks 你可以使用分层数据模板 http
  • 如何在MVVM中管理多个窗口

    我知道有几个与此类似的问题 但我还没有找到明确的答案 我正在尝试深入研究 MVVM 并尽可能保持纯粹 但不确定如何在坚持模式的同时启动 关闭窗口 我最初的想法是向 ViewModel 发送数据绑定命令 触发代码来启动一个新视图 然后通过 X
  • WPF DataGridTemplateColumn 组合框更新所有行

    我有这个 XAML 它从 ItemSource 是枚举的组合框中选择一个值 我使用的教程是 http www c sharpcorner com uploadfile dpatra combobox in datagrid in wpf h
  • 如何从 XAML 设置 WPF 用户控件属性?

    我试图从 XAML 设置同一用户控件的多个实例的 fill 属性 以便区分它们 我在控件的 C 代码隐藏中使用依赖属性 并在实例化控件时在 XAML 中引用该属性 这是我尝试过的简化示例 首先是用户控件的 XAML
  • 访问 XAML 中的静态字段

    如何在 xaml 中引用类的静态属性 换句话说 我想做这样的事情 Class BaseThingy public static readonly Style BaseStyle
  • 如何从作为 UWP 运行的 WPF 应用程序处理文件激活?

    我有一个WPF我想要处理文件激活的应用程序 我找到了通过向注册表添加特定值来解决问题的解决方案 问题是最终的应用程序应该是UWP应用程序 我正在使用桌面桥来执行此操作 如果应用程序运行为UWP 它无法到达注册表来设置这些特定值 有没有其他方
  • 如何销毁或分离 CollectionView

    我观察到 WPF ItemsControls 的奇怪行为 如果将 ItemsSource 设置为实现INotifyCollectionChanged然后设置ItemsSource为空 则CollectionView创建它是为了向 Items

随机推荐

  • 如何使用Android不支持的java core lib?

    android中使用核心类时出现问题 DX 处理 javax xml bind Binder class 时遇到问题 我确实需要 javax xml 中的类来开发 Web 服务 但是 Android 不完全支持它 当我导入这些罐子时 有 e
  • 使用某种编程语言(JS/C#..)计算RSI(相对强度指数)

    我正在努力计算RSI Relative Strength Index 我有这样的数据 Date Close Change Gain Loss 计算公式是 RSI 100 100 1 RS where RS Average Gain Aver
  • ASP.NET Core Route 属性在整个控制器类中可用

    有没有办法让路由中指定的属性在整个类中可用 例如 考虑这个控制器 Route api store storeId controller public class BookController HttpGet id int min 1 pub
  • 使用 WooCommerce 中的电子邮件 ID 定位特定电子邮件通知

    我在 WooCommerce 中设置了自定义状态和自定义电子邮件 我想使用当前的电子邮件 WC Email 而不是电子邮件模板内变量的当前状态 我需要在电子邮件模板中添加一些 if 语句 我没有使用订单状态来确保如果手动重新发送来自订单的电
  • 为什么我的内核模块中出现“不适合设备的 ioctl”错误?

    设备错误的 ioctl 不适当 嘿 我在尝试构建内核模块时遇到问题 它是一个名为message slot 的字符设备模块 根据说明 它应该最多支持 256 个未成年人 所有专业相同 235 个 每个次要代表一个不同的设备文件 最多可以有 2
  • 等待 su 中的命令完成

    我正在运行一个suAndroid 中的进程本身运行 screencap 实用程序 system bin screencap 每次用户摇晃手机时 我想等待每个屏幕截图完成 然后再允许用户通过摇动手机拍摄另一个屏幕截图 然而 使用process
  • 如何使用 ffmpeg 应用多个过滤器和输入

    我不仅有多个过滤器 而且有多个要覆盖的输入 我通常需要 2 3 个步骤来完成它们 并且想知道如何用一个命令完成所有这一切 因为这应该是最有效的方法 1和2字面意思相同 为了便于阅读 我删除了非常长且复杂的实际过滤器 图像向左滑到视频上 取1
  • 获取 char 输入并将其存储在数组中

    我想获取 n 个输入并将其保存在数组 c 和 p 中 然后使用它们 我目前已经写了这个 但我没有得到想要的输出 include
  • sympy 中的复数:解析欧拉恒等式

    我正在使用 sympy python 3 中的复杂函数 但无法让 sympy 简化方程 特别是我无法使用欧拉恒等式将复指数分解为实部和虚部 这是我的代码 import sympy as sym from sympy import I ini
  • 查询数据表字段包含列表中任何项目的行

    我是 LINQ 的新手 我想查询描述列字符串 示例值 我今天感觉很幸运 包含 匹配 a 中的任何项目的所有行List
  • S3 存储桶操作不适用于任何资源

    我正在按照以下指示进行操作这个答案 https stackoverflow com a 23102551 773263生成以下 S3 存储桶策略 Id Policy1495981680273 Version 2012 10 17 State
  • 如何使用 com.android.camera.action.CROP 设置输出图像

    我有裁剪图像的代码 如下所示 public void doCrop Intent intent new Intent com android camera action CROP intent setType image List
  • 如何为python3.4.2安装pysqlite

    i use kali linux and i need sqlite3 driver for python3 4 2 i tried the pysqlite install but get an erorr pls help me how
  • JS SDK 与 PHP SDK

    从我对各个网站的简要探索来看 JS SDK 似乎比 PHP SDK 更常用 即使是用 PHP 实现的网站也使用 JS SDK PHP 参考页面有 776 个赞 而 JS 参考页面有 20k 个赞 PHP 参考页面说 PHP SDK 可以帮助
  • 任何 redis 调用的 ioredis send 命令的默认超时是多少

    我将 ioredis 与节点应用程序一起使用 由于集群中的一些问题 我开始得到 集群重定向过多 最后一个错误 错误 连接已关闭 由于这个原因 我的所有 redis 调用都失败了 并且经过了很长一段时间 从 1 秒到 130 秒 ioredi
  • “精化”的反义词是什么

    在世界上通用编程的概念细化很常见 特别是给定一个概念C1 那么我们说一个概念C2提炼C1如果它提供了所有功能C1甚至可能更多 怎么称呼逆关系呢 因此 如果C2是一个细化C1 then C1是一个什么C2 语言学中有两个术语定义了本主题中讨论
  • 如何在 BigQuery UDF 主体内声明变量?

    我试图在 BigQuery 上创建一个带有 while 循环的 UDF 函数 但我在文档中没有看到任何专门解决这种情况的语法指南 也没有解决 UDF 正文中变量的声明 上下文 我正在尝试构建一个函数来将标题大小写应用于字符串 I tried
  • 将 dplyr tbl 列提取为向量

    是否有一种更简洁的方法可以从具有数据库后端的 tbl 中获取 dplyr tbl 的一列作为向量 即数据框 表不能直接成为子集 require dplyr db lt src sqlite tempfile create TRUE iris
  • 如何在Python中删除重复的短语?

    假设我有一个字符串 例如 I hate some kinds of duplicate This string has a duplicate phrase duplicate phrase 我想删除第二次出现的duplicate phra
  • 更改日历项目的前景色

    我正在 WPF 中自定义日历控件 并且可以调整背景颜色 标题前景色等 但我找不到如何编辑 1 31 天日历项目的外观 在 截屏 正如您所看到的 这些数字都是深灰色的 几乎不可读 我还想去掉鼠标悬停时的蓝色覆盖层 Code