我想创建控制,将采取ItemsSource和InnerTemplate并会显示包裹在所有项目CheckBoxES.
该控件有2个依赖属性:
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(CheckBoxWrapperList), null);
public static readonly DependencyProperty InnerTemplateProperty = DependencyProperty.Register("InnerTemplate", typeof(DataTemplate), typeof(CheckBoxWrapperList), null);
Run Code Online (Sandbox Code Playgroud)
这是模板:
<ControlTemplate TargetType="local:CheckBoxWrapperList">
<Grid>
<Grid.Resources>
<DataTemplate x:Key="wrapper">
<CheckBox>
<ContentPresenter ContentTemplate="{TemplateBinding InnerTemplate}" Content="{Binding}" />
</CheckBox>
</DataTemplate>
</Grid.Resources>
<ItemsControl ItemTemplate="{StaticResource wrapper}" ItemsSource="{TemplateBinding ItemsSource}" />
</Grid>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)
但是,这种方法不起作用.
在ControlPresenter.ContentTemplate使用TemplateBinding中绑定不起作用.
但是,当我不使用模板绑定并将模板作为静态资源引用时,它会按预期工作.
提前致谢.
在ayende 博客关于NHibernate审计的评论中,提到了使用子会话的必要性:session.GetSession(EntityMode.Poco).
据我所知,它与session.Flush将发出的SQL操作的顺序有关. (例如:如果我想在插入前事件中执行一些删除操作,但会话已经完成了删除操作,我需要一些方法将它们注入.)
但是,我没有找到有关此功能和行为的文档.
问题:
我对儿童会话的理解是否正确?
我应该如何以及在哪些场景中使用它们?
它们是否在某处记录?
他们可以用于会议"范围界定"吗?
(例如:我打开主会话,它将保存一些数据,然后我从主数据库中创建2个子会话.我希望这两个子范围将被分开但是将从主会话缓存共享对象是这样的吗?)
他们是NHibernate的一等公民还是他们只是支持一些边缘情况?
在此先感谢您的任何信息.
我的代码对"应该"正确的数据进行操作.但是在开发期间,我偶尔会获得无效数据.
当发生这种情况时,我想提出调试断言,如果用户选择继续,代码将过滤掉无效记录并继续操作"安全"数据.
// assert incorrect data
Debug.Assert(person.Items.All(item => item.IsValid), "Inconsistent data!");
// operate on filtered data
this.ItemViewModels = new ObservableCollection<ItemViewModel>(
person.Items
.Where(i =>item.IsValid) // Use only correct data
.Select(i => new ItemViewModel(lang, i)));
Run Code Online (Sandbox Code Playgroud)
当我选择对过滤后的数据进行操作时,我想对代码路径进行单元测试.
问题:有没有办法在单元测试中通过断言调用?
有些相当于点击OK=Continue"断言失败"对话框?
TIA
我想为数据契约序列化类创建/推断模式.
当我使用[DataContract(IsReference = true)]属性时,序列化程序会注入属性z:Id="i2"并z:Ref="i2"引用相同的对象实例.
两个属性都来自http://schemas.microsoft.com/2003/10/Serialization/命名空间.
问题:
xs:ID/ xs:IDREFpair.那是对的吗?提前致谢.
c# xsd xml-serialization datacontract datacontractserializer
c# ×2
assertions ×1
datacontract ×1
datatemplate ×1
nhibernate ×1
silverlight ×1
unit-testing ×1
xsd ×1