小编Wal*_*her的帖子

如何在EF6 Code First中创建与枚举对应的表?

我已经跟踪MSDN如何处理EF6的Code First中的枚举.它起作用,但是在创建的表中引用枚举器的字段是一个简单的int.

我更喜欢生成第二个表,其值将遵循C#代码中枚举数的定义.因此,我不想仅在MSDN上的示例中获取与Department对应的表,而是还希望看到由Faculty中的项填充的第二个表.

public enum Faculty { Eng, Math, Eco }     

public partial class Department 
{ 
  [Key] public Guid ID { get; set; } 
  [Required] public Faculty Name { get; set; } 
}
Run Code Online (Sandbox Code Playgroud)

在研究这个问题时,我偶然发现了一个解决方案,它建议为枚举创建一个表并通过种子显式填充它.

在我看来,这是一种繁琐的方法和许多应该自动处理的工作.毕竟,系统知道构成枚举的实际值.从数据库的角度来看,它仍然是数据行,就像我创建的实体一样,但从OO方面来说,它实际上并不是一个数据 - 而是一种类型(松散表达),它可以假设一个有限的和预先知道的状态数.

是否建议"手动"填充表格的方法?

c# enums entity-framework ef-code-first entity-framework-6

55
推荐指数
5
解决办法
4万
查看次数

Visual Studio 2022 中 => 和 == 运算符的显示

在 Visual Studio 2022 中,一些运算符(如 == 和 =>)以特殊方式显示:

在此输入图像描述

我宁愿把它关掉,但我还没有找到办法。

c# fonts ligature visual-studio-2022

24
推荐指数
2
解决办法
1万
查看次数

如何使文本框展开以填充网格单元格的剩余空间?

我有以下窗口和一些输入textboxes.但是这些文本框不会扩展以填充第二列的剩余空间.此外,当窗口调整大小时,textboxes不会相应调整大小,

这是我的窗口

在此输入图像描述

这是我的XAML标记

<Window x:Class="WpfApplication8.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">

    <Grid ShowGridLines="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="28"></RowDefinition>
        </Grid.RowDefinitions>

        <Label Content="First Name" Grid.Column="0" Grid.Row="0"></Label>
        <Label Content="Last Name" Grid.Column="0" Grid.Row="1"></Label>
        <Label Content="Street Name" Grid.Column="0" Grid.Row="2"></Label>
        <Label Content="Suburb" Grid.Column="0" Grid.Row="3"></Label>
        <Label Content="City" Grid.Column="0" Grid.Row="4"></Label>

        <TextBox Width="313" Grid.Column="1" Margin="3" HorizontalAlignment="Left"/>
        <TextBox Width="313" Grid.Column="1" Grid.Row="1" Margin="3" 
                 HorizontalAlignment="Left" ></TextBox>
        <TextBox Width="313" Grid.Column="1" Grid.Row="2" Margin="3" 
                 HorizontalAlignment="Left"></TextBox>
        <TextBox …
Run Code Online (Sandbox Code Playgroud)

wpf xaml

21
推荐指数
2
解决办法
3万
查看次数

从Productivity Power Tools中删除"保存时删除和排序使用"功能在VS2017中不起作用

有没有人在Visual Studio 2017中的Productivity Power Tools中使用"删除并排序使用保存"功能有问题.它似乎不起作用.对此有何解决方案?

在此输入图像描述

productivity-power-tools visual-studio-2017

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

在Visual Studio中突出显示匹配括号

在Notepad ++中,例如当光标位于大括号旁边时,它将突出显示屏幕上相应的开始或结束大括号.

请查看以下链接,了解我的意思. http://www.atmel.com/webdoc/visualassist/visualassist._match.html

Visual Studio如何做到这一点?

highlight visual-studio-2013

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

WPF设置父级(Window)

如果要将WPF窗口的父级显示为对话框,如何设置其父级?Show()和ShowDialog()似乎都没有这个选项.

这在Java中是可能的,因为您可以在构造函数中传递父级.在WPF中有可能以任何方式吗?

编辑:我正在使用C#

c# wpf window

7
推荐指数
2
解决办法
1万
查看次数

WPF字体中不可预知的不透明行为

我在理解WPF中的不透明度时遇到了问题.我在下面发布了代码.我的问题是:

  • 为什么矩形和字体会有不同的颜色?
  • 当我更改字体大小时,为什么两个TextBlock都会得到不同的颜色?

我希望,当我用颜色选择器窥探颜色时,黑色和50%的不透明度会渲染#7F7F7F,但我会得到#C2C2C2用于较小的TextBlock,而预期的#7F7F7F用于较大的字体和矩形.

问题已在https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/408部分询问,但未得到妥善解答.

任何帮助表示赞赏!

代码是:

<Window x:Class="WpfPlay.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfPlay"
        mc:Ignorable="d"
        Title="MainWindow" Height="800" Width="800" Background="White">

    <Window.Resources>
        <SolidColorBrush x:Key="ForeBrush" Color="Black" Opacity="0.5"/>
        <SolidColorBrush x:Key="BackBrush" Color="White" Opacity="1.0"/>
        <Style TargetType="TextBlock" x:Key="TextBlockStyle">
            <Setter Property="Foreground" Value="{StaticResource ForeBrush}"/>
            <Setter Property="Background" Value="{StaticResource BackBrush}"/>
            <Setter Property="FontSize" Value="48"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>

        <Style TargetType="TextBlock" x:Key="TextBlockLargeStyle">
            <Setter Property="Foreground" Value="{StaticResource ForeBrush}"/>
            <Setter Property="Background" Value="{StaticResource BackBrush}"/>
            <Setter Property="FontSize" Value="100"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>
    </Window.Resources>

    <StackPanel Orientation="Vertical" Background="White">
        <TextBlock Text="Click me" HorizontalAlignment="Center" Style="{StaticResource TextBlockStyle}" Margin="20"/>
        <TextBlock Text="Click me" …
Run Code Online (Sandbox Code Playgroud)

wpf rendering colors opacity

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

Windows 8 RT - 动态生成html不呈现图像

在LocalState目录中,我无法在网页上加载图像.

特别是,当文件路径引用LocalState目录时,尝试启动网页时似乎存在安全问题.

当我右键单击html文件并在Visual Studio中的浏览器中查看时,网页会加载图像.

我已将src标记的路径更改为:src ="ms-appdata:///Local/Logo.jpeg"它不起作用.

帮我...

示例代码

public static async Task Update(WebView webview, IStorageFile file) { 
  var html = await Windows.Storage.PathIO.ReadTextAsync(file.Path);
  webview.NavigateToString(html);
 } 
Run Code Online (Sandbox Code Playgroud)

windows-8 winrt-xaml

5
推荐指数
1
解决办法
903
查看次数