我想改变不同植物种类分布的不同地图文件的名称.
现在他们有物种的全名,如:
Amaranthus australis.kml
Capsicum annuum.kml
Cucurbita moschata.kml
Ipomoea alba.kml
Persea donnell-smithii.kml
Run Code Online (Sandbox Code Playgroud)
我想用每个单词的前3个字符来命名它们,如下所示:
ama_aus.kml
cap_ann.kml
cuc_mos.kml
ipo_alb.kml
Per_don.kml
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在R中这样做?
我在wpf c#中这样做,我试图从数据库中填充一些记录.有21条记录.
以下是我的代码的样子:
private void PopulateQuestion(int activityID, int taskID)
{
IList<ModelSQL.question> lstQuestion = qn.GetRecords(taskID, activityID);
for( int i= 0 ; i<=lstQuestion.Count()-1; i++)
{
TextBlock tb = new TextBlock();
tb.FontSize = 19;
tb.FontWeight = FontWeights.Bold;
tb.Text = lstQuestion[i].QuestionContent;
tb.TextWrapping = TextWrapping.WrapWithOverflow;
wrapPanel1.Children.Add(tb);
TextBox tbox = new TextBox();
if (lstQuestion[i].Answer.Trim().Length > 0)
{
tbox.FontSize = 19;
tbox.Width = 100;
tbox.Height = 40;
tbox.PreviewDrop += new DragEventHandler(tbox_PreviewDrop);
tbox.Focusable = false; // Disallow user to input anything into it.
wrapPanel1.Children.Add(tbox);
}
answers.Add(lstQuestion[i].Answer);
if (lstQuestion[i].QuestionNo …Run Code Online (Sandbox Code Playgroud) 好的,所以我为键盘创建了一个用户控件.它看起来像这样:

这个代码是:
<DockPanel DockPanel.Dock="Left">
<StackPanel DockPanel.Dock="Left">
<Button Content="1"
Height="60"
Width="60"
Margin="8"
Name="bttnOne" />
<Button Content="4"
Height="60"
Width="60"
Margin="8"
Name="bttnFour" />
<Button Content="7"
Height="60"
Width="60"
Margin="8"
Name="bttnSeven" />
<Button Content="0"
Height="60"
Width="60"
Margin="8"
Name="bttnZero" />
</StackPanel>
<StackPanel DockPanel.Dock="Left">
<Button Content="2"
Height="60"
Width="60"
Margin="8"
Name="bttnTwo" />
<Button Content="5"
Height="60"
Width="60"
Margin="8"
Name="bttnFive" />
<Button Content="8"
Height="60"
Width="60"
Margin="8"
Name="bttnEight" />
<Button Content="."
Height="60"
Width="60"
Margin="8"
Name="bttnDecimal" />
</StackPanel>
<DockPanel DockPanel.Dock="Left">
<StackPanel DockPanel.Dock="Bottom">
<Button Content="Del"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Width="Auto"
Margin="8"
Height="60"
Name="bttnDelete" />
</StackPanel> …Run Code Online (Sandbox Code Playgroud) 嗨我在myClass中使用此代码来更改我的wpf applciation中的内容
public event PropertyChangedEventHandler PropertyChanged;
protected void Notify(string propertyName)
{
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Run Code Online (Sandbox Code Playgroud)
每当我更改myClass中的属性时,它都会更改我在应用中的标签.
<Label Content="{Binding Category}" Padding="7,0,0,0" />
Run Code Online (Sandbox Code Playgroud)
这工作得很好,但在myClass我有一个属性包含一个ilist到另一个类文章
private IList<Article> m_articles = new List<Article>();
Run Code Online (Sandbox Code Playgroud)
现在我的问题Notify方法不会更新我的Ilist中的内容是否有我的方式来使用ilist和视图进行更新.myclass中的所有属性如果是字符串或int都可以正常工作但是当它是Ilist时它不会更新.希望你们明白我的意思我的英语是坏sry ...感谢您的帮助
这里是xaml中的代码
<ListBox Name="ArtInfo" ItemsSource="{Binding Path=Articles}">
<ListBox.ItemTemplate>
<DataTemplate>
<Label Content="{Binding Artnr}" />
</DataTemplate>
</ListBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
{Binding Path = Articles} < - 这是包含ilist的属性< - 这是Article类中的属性
我发现当我创建依赖属性时,大多数都与UserControl中的属性名称冲突,例如背景,宽度等.所以我的策略是在我的所有自定义属性前加上"The",所以我有,例如
等等
我尝试使用"new"关键字来消除警告,但这会导致运行时发生冲突.
有没有人在自定义用户控件中为DependencyProperties提供更好的命名策略?
public partial class SmartForm : UserControl
{
public SmartForm()
{
InitializeComponent();
DataContext = this;
TheBackground = "#FFD700";
}
#region DependencyProperty: TheBackground
public string TheBackground
{
get
{
return (string)GetValue(TheBackgroundProperty);
}
set
{
SetValue(TheBackgroundProperty, value);
}
}
public static readonly DependencyProperty TheBackgroundProperty =
DependencyProperty.Register("TheBackground", typeof(string), typeof(SmartForm),
new FrameworkPropertyMetadata());
#endregion
}
Run Code Online (Sandbox Code Playgroud) 我花了20分钟试图在C#中找到一个如何在两个矩形之间画一条线的例子,我找不到任何东西.我不知道我是不是不理解在Silverlight中绘制2D形状的范例,或者我只是在寻找错误的地方.
我已经设置了矩形,所以我可以拖动它们,现在我想在画布上拖动一个矩形时在两个形状之间画一条线.当我拖动第二个矩形时,我希望能够做到这样的事情:
void host1_MouseLeftButtonMove(object sender, MouseEventArgs e)
{
if (isDown)
{
this.host1TranslateTransform.X = e.GetPosition(canvas).X - x;
this.host1TranslateTransform.Y = e.GetPosition(canvas).Y - y;
Line l = new Line();
l.X1 = rect1.X; // does not work
l.X2 = e.GetPosition(canvas).X;
l.Y1 = rect1.Y; // does not work
l.Y2 = e.GetPosition(canvas).Y;
}
}
Run Code Online (Sandbox Code Playgroud)
如何获取第一个框的坐标?我无法弄清楚如何在我的应用程序中获取相对于画布的形状坐标.我将非常感谢任何有关如何绘制简单2D形状的初学者概述的教程.
谢谢!
我在 WPF 中有一个控件我想在该控件上伪造鼠标按下,使用鼠标左键我正在尝试 myControl.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1,0,0,0))
但它给了我“无法在这里访问受保护的方法”
有人有想法吗?
谢谢
好吧,我有一个ItemsControl绑定到a List<IComparableObject>,每一秒List对象都会改变,所以我不得不求助它们,所以我每秒都调用这个List.Sort()方法.在VS2008中检查Watch面板,我可以告诉它List被排序,但是ItemsControl没有.我怎样才能做到这一点?
谢谢!
private Incident incident = null;
incident = (Incident)(rdc.Incidents.Where(i => i.ID == ID));
Run Code Online (Sandbox Code Playgroud)
我得到以下异常:
无法将类型为"System.Data.Linq.DataQuery`1 [WPF.Incident]"的对象强制转换为"WPF.Incident".
我需要一个事件实例来像这样使用它:
IList listInjury = ((IListSource)incident.Incident_Injuries.OrderBy(m => m.Employee.LastName)).GetList();
Run Code Online (Sandbox Code Playgroud) wpf ×8
c# ×3
button ×1
canvas ×1
casting ×1
data-binding ×1
file ×1
for-loop ×1
itemscontrol ×1
linq ×1
menuitem ×1
mouseevent ×1
r ×1
silverlight ×1
sorting ×1
uielement ×1
xaml ×1