我想绑定到我的DataContext中的Count /项目数量.
我有一个对象,让我说有List<address>一个属性的人.我想显示该人的地址数量,即:5或6或任何情况.
我已经尝试{Binding Path=address#.Count}过其他一些但是看起来似乎没有用.
任何帮助将不胜感激,谢谢.
如何将当前窗口作为参数传递给命令?
我喜欢在XAML-markup中执行此操作:
<Button Command="CommandGetsCalled" CommandParameter="-this?-" />
Run Code Online (Sandbox Code Playgroud) 使用.load,我将以下内容加载到#step_2 div中:
<div id="step_2">
Select a subcategory:
<select id="subcategory_id" name="subcategory_id">
<option value="0">All subcategories</option>
<option value="68">Cool</option>
<option value="15">Cooler</option>
<option value="74">Excellent</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
然后我试图检测用户选择的东西:
$("#subcategory_id").on("change", function(){
alert( 'Success!' );
});
Run Code Online (Sandbox Code Playgroud)
但没有成功.有谁看到我做错了什么?非常感谢.
笔记:
这是FireBug看到的完整CSS路径:
html.js body div#container div#main form div#step_2 select#subcategory_id
Run Code Online (Sandbox Code Playgroud)
这是完整的javascript文件,如果上下文很重要:
$(document).ready(function() {
$("#category_id").change(function() {
$("#spinner").show();
$("#step_2").load("process.php?selected=category", { value: $(this).val() }, function() {
// Do something to say the data has loaded sucessfully
$("#spinner").hide();
});
});
$("#subcategory_id").on("change", function(){
alert( 'Success!' );
});
});
Run Code Online (Sandbox Code Playgroud) 你能绑定到这样的局部变量吗?
SystemDataBase.cs
namespace WebWalker
{
public partial class SystemDataBase : Window
{
private string text = "testing";
...
Run Code Online (Sandbox Code Playgroud)
SystemDataBase.xaml
<TextBox
Name="stbSQLConnectionString"
Text="{SystemDataBase.text}">
</TextBox>
Run Code Online (Sandbox Code Playgroud)
??
文本设置为局部变量"text"
我想为DateTime类型编写自己的模型绑定器.首先,我想写一个我可以附加到我的模型属性的新属性,如:
[DateTimeFormat("d.M.yyyy")]
public DateTime Birth { get; set,}
Run Code Online (Sandbox Code Playgroud)
这是简单的部分.但是粘合剂部分有点困难.我想为类型添加一个新的模型绑定器DateTime.我也可以
IModelBinder接口并编写我自己的BindModel()方法DefaultModelBinder和覆盖BindModel()方法我的模型有如上所示的属性(Birth).因此,当模型尝试将请求数据绑定到此属性时,BindModel(controllerContext, bindingContext)将调用我的模型绑定器.一切都好,但是.如何从controller/bindingContext获取属性属性,以正确解析我的日期?我怎样才能到达PropertyDesciptor房产Birth?
由于关注点的分离,我的模型类是在一个没有(也不应该)引用System.Web.MVC程序集的程序集中定义的.设置自定义绑定(类似于Scott Hanselman的示例)属性是禁止的.
我有ItemsControl绑定到Student类型的集合.在ItemTemplate中我有一个TextBox,它使用IValueConverter来做一些自定义计算和逻辑.我想将实际的Student对象传递给值转换器,而不是它的属性.我怎样才能做到这一点?这是我的代码示例.
<ItemsControl ItemsSource="{Binding StudentList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
<TextBlock Text="{Binding ????, Converter={StaticResource MyConverter}}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
在代码我有这个
public class MyValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
// I want 'value' to be of type Student.
return null;
}
}
Run Code Online (Sandbox Code Playgroud) 我想知道什么,找不到任何相关的主题.我有以下绑定:
Content="{x:Static resx:Resource.Form_OtherOption_Description}"
Run Code Online (Sandbox Code Playgroud)
这将在标签中放置一个字符串.我问自己的是,如果我可以在绑定之后添加":",而不是在代码中,只需在xaml中添加.标签代表"名称:".但添加":"作为绑定的一部分不是一种选择.
编辑
我在3.5版本工作
有什么建议.
提前致谢.
我的视图模型中有一个对象,它有一堆属性,其中一些偶尔会为null.如果这些特定控件为null,我不想只显示一些控件.如果绑定为null,我将如何隐藏控件?我在想某种转换器,但不知道我是怎么做的.有任何想法吗?
编辑:对不起,我应该提一下,这也将在Silverlight中,所以我不确定Style触发器是否会起作用......?
我binding在以下问题中阅读了有关属性的组件绑定:
据我所知,它将视图中JSF标记后面的UI组件绑定到UIComponent辅助bean中的属性.但是,我很困惑组件绑定的用途以及何时应该使用它.有人可以用更简单的方式解释它并给出一些实际的例子吗?
我有多个视频显示它们与Mainviewmodel中的视频选择绑定.一切正常,直到我尝试将enter命令绑定到Mainviewmodel.我不知道这个的语法.目前,绑定设置为Video而不是Mainviewmodel.
错误信息:
'StartVideoCommand' property not found on 'object' ''Video'
Run Code Online (Sandbox Code Playgroud)
XAML:
<Window.Resources>
<local:MainViewModel x:Key="MainViewModel"/>
</Window.Resources>
<Grid DataContext="{StaticResource MainViewModel}">
<ListBox ItemsSource="{Binding Videos}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.InputBindings>
!!! <KeyBinding Key="Enter" Command="{Binding StartVideo}" /> !Bound to Video not to Mainviewmodel grrr
</Grid.InputBindings>
... layout stuff
<TextBlock Text="{Binding Title}" Grid.Column="0" Grid.Row="0" Foreground="White"/>
<TextBlock Text="{Binding Date}" Grid.Column="0" Grid.Row="1" Foreground="White" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding Length}" Grid.Column="1" Grid.Row="1" Foreground="White" HorizontalAlignment="Right"/>
... closing tags
Run Code Online (Sandbox Code Playgroud) binding ×10
wpf ×7
asp.net-mvc ×1
c# ×1
components ×1
data-binding ×1
datacontext ×1
datatemplate ×1
events ×1
itemtemplate ×1
jquery ×1
jsf ×1
modelbinders ×1
parent ×1
silverlight ×1
viewmodel ×1
xaml ×1