这是XAML标记:
<ScrollViewer Grid.Column="1" Grid.Row="2" HorizontalScrollBarVisibility="Disabled" Width="990">
<StackPanel Margin="50 0 0 40">
<ItemsControl x:Name="streamList" ItemsSource="{Binding StreamInformations}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="10" Orientation="Horizontal" >
<StackPanel Orientation="Horizontal">
<Image Source="{Binding ImageUrl}" Height="60" />
<StackPanel Margin="10 0 0 0" VerticalAlignment="Center">
<TextBlock Foreground="Black" Text="{Binding ChannelName}" FontSize="12" />
<TextBlock Foreground="#999" Text="{Binding PlayerName}" FontSize="10" />
<TextBlock Foreground="#999" Text="{Binding ViewCount}" FontSize="10" />
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
这就是它的样子:

我希望这些项目水平显示并在到达StackPanel边缘时向下流动.
目前看来,我的DataContext集合中的每个项目都在创建自己的StackPanel,所以这不是我想要的.
有什么建议?
这是我解雇的那条线:
git remote add Nakor git://github.com.nakor/CherryTomato.git
Run Code Online (Sandbox Code Playgroud)
我犯了一个错误,命令应该是:
git remote add Nakor git://github.com/nakor/CherryTomato.git
Run Code Online (Sandbox Code Playgroud)
当我尝试运行第二个命令时,我收到此错误:
fatal: Remote Nakor already exists.
Run Code Online (Sandbox Code Playgroud)
这是可以理解的.如何编辑遥控器Nakor指向的端点?
这是我的XAML:
<ListBox Grid.Row="1" x:Name="lstGames" Background="#343434" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding ImageUrl}" Width="100"/>
<StackPanel Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Title:" />
<TextBlock Text="{Binding Title}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Release Date:" />
<TextBlock Text="{Binding ReleaseDate}" />
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
如果没有放置矩形并在DataTemplate内部给它一种颜色,那么ListBox是否有某种方式可以在每个项目之间进行原生设置?
我正在尝试运行此代码,我得到一个例外:
指数超出范围.必须是非负数且小于集合的大小.参数名称:index
private void LoadStudentGrades(int gradeParaleloId, int subjectId)
{
GradeStudentRepository gradeStudentRepo = new GradeStudentRepository();
students = gradeStudentRepo.FindAllGradeStudents().Where(g => g.GradeParaleloId == gradeParaleloId)
.Select(g => g.Student);
int i = 1;
foreach (var student in students)
{
DataGridViewRow row = new DataGridViewRow();
row.Cells[0].Value = i.ToString();
row.Cells[1].Value = student.LastNameFather + " " + student.LastNameMother + ", " + student.Name;
dataGridView1.Rows.Add(row);
i++;
}
}
Run Code Online (Sandbox Code Playgroud)
我在datagridview中手动创建了列,现在我想使用这个小方法填充字段.
在Visual Studio中,当我按下F5这个特定的MVC3项目时,它会打开:
localhost:36185/Views/Auction/Details.cshtml
Run Code Online (Sandbox Code Playgroud)
在任何其他项目中,当我F5正确按下它时打开Home/Index动作方法:
http://localhost:36185
Run Code Online (Sandbox Code Playgroud)
为什么打开特定的View而不是使用正确的Home/Index操作?什么设置干扰?
我刚刚在Windows 7机器上下载并安装了最新版本的Python.
Python 2.7.3
Run Code Online (Sandbox Code Playgroud)
现在我想安装一个我在网上找到的Twitter库:
但是,当我尝试运行时easy_install tweepy,我收到此错误消息:
'easy_install'未被识别为内部或外部命令,可操作程序或批处理文件.
Python已经被放入我的路径,因为我可以在命令行中调用Python程序.
这是我安装Python的文件夹的屏幕截图.

在Tools文件夹中:

在scripts文件夹中:

我发现OpenID有点像一个庞大的,或者比典型的注册形式更复杂,但我觉得我在这里缺少一些东西.
根据这个问题,我应该保存我的提供商给出的唯一标识符密钥.
提供商将为每个用户提供一个唯一的ID - 您需要保存.这是您将刚刚登录的用户与数据库中的记录进行匹配的方式.
在我的代码中(取自MVC部分),这个唯一的ID在LogOn()action方法的开关内给出:
public ActionResult LogOn()
{
var openid = new OpenIdRelyingParty();
IAuthenticationResponse response = openid.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
FormsAuthentication.RedirectFromLoginPage(
response.ClaimedIdentifier, false); // <-------- ID HERE! "response.ClaimedIdentifier"
break;
case AuthenticationStatus.Canceled:
ModelState.AddModelError("loginIdentifier",
"Login was cancelled at the provider");
break;
case AuthenticationStatus.Failed:
ModelState.AddModelError("loginIdentifier",
"Login failed using the provided OpenID identifier");
break;
}
}
return View();
}
[HttpPost]
public ActionResult LogOn(string loginIdentifier)
{
if (!Identifier.IsValid(loginIdentifier))
{
ModelState.AddModelError("loginIdentifier", …Run Code Online (Sandbox Code Playgroud) 这是我的模特:
[Required]
[Display(Name = "I'm a:")]
public bool Sex { get; set; }
Run Code Online (Sandbox Code Playgroud)
我的编辑模板:
<div>
@Html.LabelFor(model => model.RegisterModel.Sex)
@Html.EditorFor(model => model.RegisterModel.Sex)
</div>
Run Code Online (Sandbox Code Playgroud)
但是,这将呈现如下:
<div>
<label for="RegisterModel_Sex">Soy:</label>
<input class="check-box" data-val="true" data-val-required="The Soy: field is required." id="RegisterModel_Sex" name="RegisterModel.Sex" type="checkbox" value="true" /><input name="RegisterModel.Sex" type="hidden" value="false" />
</div>
Run Code Online (Sandbox Code Playgroud)
我如何为男性和女性渲染一些漂亮的单选按钮?我的模型必须具有什么数据类型?
这是我新的更新代码:
//Model:
[Required]
[Display(Name = "Soy:")]
public Gender Sex { get; set; }
}
public enum Gender
{
Male = 1,
Female = 2
}
//Viewmodel:
<fieldset>
<legend>Informacion Personal</legend>
<div>
@Html.LabelFor(model => model.RegisterModel.Nombre)
@Html.EditorFor(model …Run Code Online (Sandbox Code Playgroud) 这是我的控制器代码,它可以100%正常工作.但是POST方法没有使用AutoMapper,这不行.如何在此操作方法中使用AutoMapper?
我正在使用Entity Framework 4和Repository Pattern来访问数据.
public ActionResult Edit(int id)
{
Product product = _productRepository.FindProduct(id);
var model = Mapper.Map<Product, ProductModel>(product);
return View(model);
}
[HttpPost]
public ActionResult Edit(ProductModel model)
{
if (ModelState.IsValid)
{
Product product = _productRepository.FindProduct(model.ProductId);
product.Name = model.Name;
product.Description = model.Description;
product.UnitPrice = model.UnitPrice;
_productRepository.SaveChanges();
return RedirectToAction("Index");
}
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
如果我使用AutoMapper,实体框架引用将丢失,并且数据不会持久存储到数据库中.
[HttpPost]
public ActionResult Edit(ProductModel model)
{
if (ModelState.IsValid)
{
Product product = _productRepository.FindProduct(model.ProductId);
product = Mapper.Map<ProductModel, Product>(model);
_productRepository.SaveChanges();
return RedirectToAction("Index");
}
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
我猜这是因为Mapper.Map函数返回了一个全新的Product对象,因此没有保留对实体框架图的引用.你有什么选择吗?
我被告知最好将Javascript代码放在一个单独的文件中以保持关注点分离,虽然这个想法与我产生共鸣,但我觉得它并不实用.
这可能只是我的经验不足,因此这个问题.
这是一个明确的示例,我发现将代码放在View中比将其放在单独的javascript文件中更好.
在我的视图中,我需要调用JQueryUI对话框,并使用我的模型名称动态设置标题.
$("#thumbs img").click(function () {
var url = $(this).attr("src");
$(".image-popup").attr("src", url);
return $("#image-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: '@Model.Product.Name'
});
});
Run Code Online (Sandbox Code Playgroud)
注意:
title: '@Model.Product.Name'
Run Code Online (Sandbox Code Playgroud)
如您所见,如果我在View中使用Javascript,我可以访问强类型模型.如果我使用单独的Javascript文件,则情况并非如此.
我做错了吗,有什么我没看到的吗?
如果我要使用单独的文件,看起来如何看,因为我无法从Javascript文件中访问模型属性?
c# ×7
wpf ×2
.net ×1
automapper ×1
datagridview ×1
datatemplate ×1
easy-install ×1
git ×1
itemscontrol ×1
javascript ×1
listbox ×1
model ×1
openid ×1
panel ×1
python ×1
python-2.7 ×1
steam ×1
windows-7 ×1
xaml ×1