嗨,有没有办法做这样的事情:
for (int i = 0; i < Math.Min(a.Count, b.Count); i++)
{
// Do stuff
//a[i]
//b[i]
}
Run Code Online (Sandbox Code Playgroud)
与Foreach?
因为写一些类似的东西会很好
foreach(var item1 in list1 and var item2 in list2 /* ....*/)
{
item1.use(item2);
}
Run Code Online (Sandbox Code Playgroud)
好对不起我对某些人不够清楚,所以希望能有更好的解释
List<classA> listA = fillListA();
List<classB> listB = fillListB();
//here could be infinity many lists of sometimes diffrent T types
Run Code Online (Sandbox Code Playgroud)
现在我想执行某种ForEach因为我不喜欢用for循环做它应该简单明了很好像
foreach(var item1 in list1 and var item2 in list2 /* and ...*/)
{
item1.use(item2);
}
Run Code Online (Sandbox Code Playgroud)
AFAIK我不能修改这样一个keay词类的东西,所以我认为确定构建像Parallel.ForEach那样的迭代器,ForEach<TSource>(IEnumerable<TSource>, Action<TSource>) …
我的ItemsControl用户控件中有一个滚动浏览器,当它变得太大时(太大的内容大于可视区域UserControl).问题是它所有的网格都在不断扩展,以便滚动查看器永远不会启动(除非我为网格指定了精确的高度).请参阅下面的代码,并提前感谢.
<UserControl x:Class="BusinessObjectCreationWizard.View.TableSelectionPageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<GroupBox FontWeight="Bold" Height="300px"
Header="Tables"
Padding="2">
<ScrollViewer>
<ItemsControl FontWeight="Normal"
ItemsSource="{Binding Path=AvailableTables}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Path=DisplayName}"
IsChecked="{Binding Path=IsSelected}"
Margin="2,3.5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</GroupBox>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
此处加载此用户控件
<Border Background="White" Grid.Column="1" Grid.Row="0">
<HeaderedContentControl Content="{Binding Path=CurrentPage}"
Header="{Binding Path=CurrentPage.DisplayName}" />
</Border>
Run Code Online (Sandbox Code Playgroud)
我想不指定高度.
嗨我想将DataTable多列绑定到代码DataGrid隐藏中
var dt = new DataTable();
dt.Columns.Add(new DataColumn("1"));
dt.Columns.Add(new DataColumn("2"));
dt.Columns.Add(new DataColumn("3"));
dt.Rows.Add(ff.Mo);
dt.Rows.Add(ff.Di);
dt.Rows.Add(ff.Mi);
dt.Rows.Add(ff.Do);
dt.Rows.Add(ff.Fr);
dt.Rows.Add(ff.Sa);
dt.Rows.Add(ff.So);
// ff is a object that contains List<myCellObj>
DataGrid DGrid = new DataGrid();
for (int i = 0; i < 3; i++)
{
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
templateColumn.HeaderTemplate = HeaderDt;
templateColumn.CellTemplate = ItemDt; //specified DataTemplate for myCellObj
DGrid.Columns.Add(templateColumn);
}
Run Code Online (Sandbox Code Playgroud)
现在我该怎样设置我的dt作为ItemsSource,Datacontext或什么都得到它在我View
还,如果你能提供给我直接绑定到我的路Object ff
任何可能有用的东西都非常感激
嗨,我正在努力了解如何构建一个可读的,也可以防止Fluent-API出错,而不会对用户造成太大限制
保持简单让我们说我们想要改变下面的课程,以便流利
public class Car
{
public int Gallons { get; private set; }
public int Tons { get; private set; }
public int Bhp { get; private set; }
public string Make { get; private set; }
public string Model { get; private set; }
public Car(string make, string model)
{
Make = make;
Model = model;
}
public void WithHorsePower(int bhp)
{
Bhp = bhp;
return this;
}
public void WithFuel(int gallons)
{
Gallons = gallons;
}
public …Run Code Online (Sandbox Code Playgroud) 我有自定义控件与打印工具栏项.当打印控件对话框没有进入Windows 7与64位操作系统在其他系统操作系统工作正常.仅在具有64位的Windows 7中出现问题.
我的问题printdialog没有进入64位的Windows 7操作系统.
我已检查并分析 - > PrintDialog.ShowDialog()返回immeaditely取消instaed显示该问题的对话框.
我通过搜索以下链接找到了问题的解决方案:
http://social.msdn.microsoft.com/Forums/en/netfx64bit/thread/8760fb6c-ae63-444e-9606-cd3295ce6b5d
http://msdn.microsoft.com/en-us/library/system.windows.forms.printdialog.useexdialog.aspx
通过将true设置为printdialog的UseExDialog属性,对话框出现并且工作正常.但是这个对话框样式就像Windows XP而不是windows7样式.所以这不是解决方案.
UseExDialog属性设置为true表示工作正常.但打印对话框样式看起来像Windows XP打印不像Windows 7.我需要一些其他解决方案在Windows 7 os 64位显示打印对话框.
请为此问题提供完整的解决方案
谢谢
湿婆
哪一个是保存我的数据的更好的解决方案,还是取决于某些条件?
示例情况1:
您需要显示一个数据列表,可在选择后在新窗口中修改.
示例情况2:
您需要显示可在此列表中修改的数据列表.
我想创建一个简单的游戏,类似于RPG Maker可以创建的游戏.我目前主要关注的是一个教程,它可以指导我如何在不使用XNA或任何其他特定库的情况下完成它.
理想的是一步一步的教程或一个易于理解的好例子.
我的目标是独立完成,并了解整个过程如何与彼此相关的动画元素相关.
我已经使用一个简单的教程在过去构建了一个简单的蛇游戏,但其中没有动画动画,这是我接下来要学习的主要内容.
编辑:
到目前为止,我发现的所有教程都使用第三方库.我确实遇到过这个链接,但我正在寻找不包含XNA的东西.
让我们说我们想要Convert/Parse跟随字符串
string mystring = "221021290110000123452229211210282900128222900"
Run Code Online (Sandbox Code Playgroud)
一个数字
这个数字是什么类型的?
我测试Double.TryParse(mystring,out myBigNumber)但是我得到了一个E+我不能用于我的数学运算的数字,因为模运算会导致错误的数字
目前我正面临着一个我无法解决的荒谬问题
我写了一个小包装器,它包装了几乎所有的Property并添加了一个Property但我不知道如何通过他将验证传递给我的XAML
这是我的代码
XAML
<TextBox Height="23" HorizontalAlignment="Left" Margin="42,74,0,0" Name="textBox2" VerticalAlignment="Top" Width="120"
DataContext="{Binding TB2}"/>
<!-- this Style is be added to the parent of TextBox -->
<Style TargetType="{x:Type TextBox}">
<Setter Property="Text" Value="{Binding Value,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsDirty}" Value="true">
<Setter Property="BorderBrush" Value="Orange"/>
</DataTrigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
视图模型
public class vm : IDataErrorInfo, INotifyPropertyChanged
{
[Required]
[Range(4, 6)]
public string TB1 { get; set; }
[Required]
[Range(4, 6)]
public myWrapper TB2
{
get { return tb2; }
set{
tb2 = value;
OnPropertyChanged("TB2");
}
} …Run Code Online (Sandbox Code Playgroud) 假设你有一个包含多个这样的Texbox的View
<TextBox Text="{Binding myText1, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
Run Code Online (Sandbox Code Playgroud)
每个都已包含一些文字.如果用户更改此文本,则文本框边框应更改为橙色,如果他撤消其更改,则应获取其默认颜色.
目前我这样做
<TextBox Height="23" Text="{Binding myText1, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" BorderThickness="2">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding myDirtyText1, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="BorderBrush" Value="Orange"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
有没有更通用/更简单的方法来做到这一点?
编辑
我已经在使用IDataErrorInfo+ System.ComponentModel.DataAnnotations进行错误验证.也许在这种情况下有类似的方法,但我没有发现任何有用的减少我的xaml和代码到最低限度.
我认为你并不真正了解我的问题,所以我会提供一个更好的实际样本:
<Grid Margin="12">
<Label Content="Name:" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top" Width="79" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="102,2,0,0" VerticalAlignment="Top" Width="170" BorderThickness="2"
Text="{Binding NameD, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding dirtyName, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="BorderBrush" Value="Orange"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox> …Run Code Online (Sandbox Code Playgroud)