如何将Text的属性绑定TextBox到FoundationHeight代码隐藏中定义的 clr-property。
xaml
<TextBox Text="{Binding FoundationHeight}"/>
Run Code Online (Sandbox Code Playgroud)
C#
public double FoundationHeight { get; set; }
public AssignColumnPropertiesWindow()
{
InitializeComponent();
FoundationHeight = 60;
}
Run Code Online (Sandbox Code Playgroud) 我想在 WPF 窗口中创建一个按钮,单击该按钮时,等待用户单击该窗口并获取单击的位置。一旦获取到位置,程序将继续执行下一行代码并显示点击的位置。
<Window x:Class="WpfApp1.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"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Pick Point & Display it!" HorizontalAlignment="Left" Margin="301,172,0,0" VerticalAlignment="Top" Width="168" Click="Button_Click" RenderTransformOrigin="1.479,2.177"/>
</Grid>
</Window>
private void Button_Click(object sender, RoutedEventArgs e)
{
var point = WaitTillUserClicks();
MessageBox.Show(point.ToString());
}
private Point WaitTillUserClicks()
{
// Prompt the user for a mouse click and do not proceed unless he has clicked at least once on the Window
}
Run Code Online (Sandbox Code Playgroud) 我想Polyline在 中画一个Visual Layer。这是我用来绘制 的代码Line。我应该绘制多个Lines并将它们添加到中VisualCollection还是有更好的方法?
var drawingVisual = new DrawingVisual();
using (var dc = drawingVisual.RenderOpen())
{
var myPen = new Pen
{
Thickness = thickness,
Brush = Settings.GridColor
};
myPen.Freeze();
dc.DrawLine(myPen, pt1, pt2);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用以下等式来查找两条线是否平行.但是当线条几乎平行并最终在远处相遇时,我遇到了问题.我想要一个将这两条几乎平行的线视为平行的方程式.
var la = new Line {X1 = 1005, Y1 = 773, X2 = 1202, Y2 = 1198};
var lb = new Line {X1 = 1239, Y1 = 1181, X2 = 1550, Y2 = 1856};
var d = (lb.Y2 - lb.Y1) * (la.X2 - la.X1) - (lb.X2 - lb.X1) * (la.Y2 - la.Y1);
if (Math.Abs(d) < 0.001)
{
// Return if lines are parallel
}
Run Code Online (Sandbox Code Playgroud)
令我惊讶的是,上面的公式d得出的数字远远大于0.我在这里错了什么?我使用了错误的等式吗?
我正在使用这篇文章:http: //paulbourke.net/geometry/pointlineplane/
我正在使用以下代码将MDB数据库中的表加载到Excel工作表.我正在尝试将表名定义为变量并将其传递给查询但我收到的错误与下面的代码.我怎么能这样做VBA?
Public Sub ReadMdb()
Dim cn As Object, rs As Object
Dim intColIndex As Integer
Dim DBFullName As String
Dim TargetRange As Range
DBFullName = Application.GetOpenFilename()
On Error GoTo Oops
Application.ScreenUpdating = False
Set TargetRange = Sheets("Sheet1").Range("A1")
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBFullName
Set rs = CreateObject("ADODB.Recordset")
Dim tableName As String
tableName = "Students"
rs.Open "SELECT * FROM tableName", cn, , , adCmdText
' Write the field names
For intColIndex = 0 …Run Code Online (Sandbox Code Playgroud) 假设我们有List<Item> data,并且Item类定义如下:
public class Item
{
public double Station { get; set; }
public double Area { get; set; }
...
// other properties present in the class
}
Run Code Online (Sandbox Code Playgroud)
现在我们如何创建一个新List<T>的List<Item>,所以这T是一个只有double Station和double Area作为其属性的匿名类型.
我知道如何将所有的站点和区域值提取到一个List<double> data2但我想要的是不同的.
var data2 = data
.SelectMany(x => new[] { x.Station, x.Area })
.ToList();
Run Code Online (Sandbox Code Playgroud) 我有一个Person对象列表。如何Person从List<Person> People使用中获得满足特定条件的第一个和第二个对象LINQ?
假设这是我得到的清单。我怎样才能得到第一个和第二个 18 岁以上的人,那就是詹姆斯和朱迪。
public class Person
{
public string Name;
public int age;
}
var People = new List<Person>
{
new Person {Name = "Jack", Age = 15},
new Person {Name = "James" , Age = 19},
new Person {Name = "John" , Age = 14},
new Person {Name = "Jodie" , Age = 21},
new Person {Name = "Jessie" , Age = 19}
}
Run Code Online (Sandbox Code Playgroud) 如何half-space在Textbox(非Console.Writleline语句)中在 c# 中编写字符?是否有特定的字符代码?