我已经跟踪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方面来说,它实际上并不是一个数据 - 而是一种类型(松散表达),它可以假设一个有限的和预先知道的状态数.
是否建议"手动"填充表格的方法?
我有以下窗口和一些输入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) 在Notepad ++中,例如当光标位于大括号旁边时,它将突出显示屏幕上相应的开始或结束大括号.
请查看以下链接,了解我的意思. http://www.atmel.com/webdoc/visualassist/visualassist._match.html
Visual Studio如何做到这一点?
如果要将WPF窗口的父级显示为对话框,如何设置其父级?Show()和ShowDialog()似乎都没有这个选项.
这在Java中是可能的,因为您可以在构造函数中传递父级.在WPF中有可能以任何方式吗?
编辑:我正在使用C#
我在理解WPF中的不透明度时遇到了问题.我在下面发布了代码.我的问题是:
我希望,当我用颜色选择器窥探颜色时,黑色和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) 在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)