我正在尝试在我的应用程序中打印文档.但在不同的打印机上我得到不同的结果.这是我的代码:
PaperSize paperSize = new PaperSize("My Envelope", 440, 630);
paperSize.RawKind = (int)PaperKind.Custom;
PrintDocument pd = new PrintDocument();
pd.PrintPage += (sender, args) => Console.Out.WriteLine("Printable Area for printer {0} = {1}", args.PageSettings.PrinterSettings.PrinterName, args.PageSettings.PrintableArea);
pd.DefaultPageSettings.PaperSize = paperSize;
pd.DefaultPageSettings.Landscape = true;
pd.DefaultPageSettings.Margins = new Margins(60, 40, 20, 20);
Console.Out.WriteLine("My paper size: " + pd.DefaultPageSettings.PaperSize);
PrintDialog printDialog = new PrintDialog(); // to choose printer
printDialog.Document = pd;
if (printDialog.ShowDialog(this) == DialogResult.OK)
{
// pd.DefaultPageSettings.PaperSize = paperSize; // uncomment to override size from dialog
Console.Out.WriteLine("Paper size …Run Code Online (Sandbox Code Playgroud) 我有问题是杀了我.以下是简单的例子
<Grid Name="_grid">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="36,33,0,0" Name="button" VerticalAlignment="Top" Width="75" />
<Button Content="Enlarge through animation" Height="23" Margin="172,33,24,0" Name="_animateButton" VerticalAlignment="Top" Click="_animateButton_Click" />
<Button Content="Enlarge through simple heigh changing" Height="23" Margin="172,62,24,0" Name="_resizeButton" VerticalAlignment="Top" Click="_resizeButton_Click" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
在代码背后
private void _resizeButton_Click(object sender, RoutedEventArgs e)
{
button.Height += 10;
}
private void _animateButton_Click(object sender, RoutedEventArgs e)
{
Storyboard storyboard = new Storyboard();
DoubleAnimation animation = new DoubleAnimation(button.Height + 10, new Duration(new TimeSpan(0, 0, 0, 1)));
storyboard.Children.Add(animation);
Storyboard.SetTargetName(animation, button.Name);
Storyboard.SetTargetProperty(animation, new PropertyPath(HeightProperty));
storyboard.Begin(_grid);
} …Run Code Online (Sandbox Code Playgroud) 我有两个由代码生成的简单类.
public class Company
{
public int Id { get; set; }
public string Name { get; set; }
public virtual Address Address { get; set; }
}
public class Address
{
public int Id { get; set; }
public string Country { get; set; }
...
}
Run Code Online (Sandbox Code Playgroud)
在数据库中保存公司后,我有公司(Id = 1 | name ="blah"| AddressId = 1)及其地址(Id = 1,Country ="Poland").当我尝试从我的DbContext加载时:
Company company = context.Companies.Find(id);
Run Code Online (Sandbox Code Playgroud)
我得到公司与null地址属性.我究竟做错了什么?
(我正在使用CTP5.)
我正在尝试基于msdn示例构建组合框的模板,但我有奇怪的错误.更确切地说,如果我在正常组合框中写入长文本,文本将向左移动,我们始终看到插入符号.但是在msdn例子中,当我写长文本时,插入符号正在移动到组合之外.以下是它的外观:

当我选择文本时,它看起来像这样:

我已经使用了Framework 3.5和Framework 4组合框帮助中的示例, 并且在复制和粘贴之后,我一直在遇到相同的情况.谢谢你的帮助.
编辑:
<Window x:Class="ComboBoxTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Framework 3.5" Height="350" Width="525">
<Window.Resources>
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="2" Background="White"
BorderBrush="Black" BorderThickness="1" />
<Border Grid.Column="0" CornerRadius="2,0,0,2" Margin="1" Background="#FFF"
BorderBrush="Black" BorderThickness="0,0,1,0" />
<Path x:Name="Arrow" Grid.Column="1" Fill="#444" HorizontalAlignment="Center"
VerticalAlignment="Center" Data="M 0 0 L 4 4 L 8 0 Z" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Background" Value="Black" />
</Trigger>
<Trigger Property="ToggleButton.IsChecked" Value="true">
<Setter TargetName="Border" …Run Code Online (Sandbox Code Playgroud) 我有两节课:
public class Company
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<User> Users { get; set; }
}
public class User
{
public int Id { get; set; }
public string Email { get; set; }
public virtual ICollection<Company> Companies { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的MVC应用程序控制器中从post发布新公司.我想在这样的事情中添加当前用户到创建的公司.
User user = GetCurrentLoggedUser();
//company.Users = new ICollection<User>(); // Users is null :/
company.Users.Add(user); // NullReferenceException
companyRepository.InsertOrUpdate(company);
companyRepository.Save();
Run Code Online (Sandbox Code Playgroud)
它应该如何正常工作?我还不知道但是在将用户添加到集合之后,我预计将其保存到数据库会出现问题.任何有关它应该是什么样子的提示都将不胜感激.
我正在为我的ASP MVC应用程序进行本地化,我想为每个属性设置相同的设置.
例如:
[Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "RequiredAttribute_ValidationError")]
[Display(Name = "Has?o")]
public string Password { get; set; }
Run Code Online (Sandbox Code Playgroud)
有没有办法自动完成?
我很难理解如何在F#中定义类,其中我有没有声明值的属性.等同于c#代码的东西:
class Entity
{
public string Name { get; set; }
public List<string> Favorites { get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我只能声明类型定义的类型
type Entity =
member val Name = "" with get, set
Run Code Online (Sandbox Code Playgroud)
当我指定null时,Name的类型将为null.
c# ×5
wpf ×2
animation ×1
asp.net-mvc ×1
attributes ×1
c#-4.0 ×1
c#-to-f# ×1
code-first ×1
combobox ×1
f# ×1
printing ×1
winforms ×1