我有一个窗口中包含的列表(见下文).窗口DataContext有两个属性,Items和AllowItemCommand.
如何获取针对窗口的属性需要解析Hyperlink的Command属性DataContext?
<ListView ItemsSource="{Binding Items}">
<ListView.View>
<GridView>
<GridViewColumn Header="Action">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock>
<!-- this binding is not working -->
<Hyperlink Command="{Binding AllowItemCommand}"
CommandParameter="{Binding .}">
<TextBlock Text="Allow" />
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud) 目前,我读过的所有内容都表明您必须将MongoDB作为单独的进程/服务运行.有没有办法在进程中托管MongoDB?如果不是现在,他们已知的计划是否实施这样的功能?
更新的问题给出了Andrew Hare的正确答案:
鉴于以下C#类:
public class Bar : Foo, IDisposable
{
// implementation of Bar and IDisposable
}
public class Foo : IEnumerable<int>
{
// implementation of Foo and all its inherited interfaces
}
Run Code Online (Sandbox Code Playgroud)
我想要一个类似下面的方法,它不会在断言上失败(注意:你不能改变断言):
public void SomeMethod()
{
// This doesn't work
Type[] interfaces = typeof(Bar).GetInterfaces();
Debug.Assert(interfaces != null);
Debug.Assert(interfaces.Length == 1);
Debug.Assert(interfaces[0] == typeof(IDisposable));
}
Run Code Online (Sandbox Code Playgroud)
有人可以通过修复此方法来帮助断言不会失败吗?
呼叫typeof(Bar).GetInterfaces()不起作用,因为它返回的整个界面的层次结构(即interfaces变量包含IEnumerable<int>,IEnumerable和IDisposable),而不仅仅是顶层.
c# ×1
class ×1
data-binding ×1
datacontext ×1
hosting ×1
interface ×1
mongodb ×1
reflection ×1
wpf ×1