小编Jor*_*dan的帖子

WPF数据绑定:如何访问"父"数据上下文?

我有一个窗口中包含的列表(见下文).窗口DataContext有两个属性,ItemsAllowItemCommand.

如何获取针对窗口的属性需要解析HyperlinkCommand属性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)

data-binding wpf datacontext

202
推荐指数
3
解决办法
16万
查看次数

MongoDB可以在进程中托管吗?

目前,我读过的所有内容都表明您必须将MongoDB作为单独的进程/服务运行.有没有办法在进程中托管MongoDB?如果不是现在,他们已知的计划是否实施这样的功能?

hosting mongodb

12
推荐指数
1
解决办法
2948
查看次数

如何枚举在继承类上直接定义的接口列表?

更新的问题给出了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>,IEnumerableIDisposable),而不仅仅是顶层.

c# reflection interface class

8
推荐指数
1
解决办法
1479
查看次数

标签 统计

c# ×1

class ×1

data-binding ×1

datacontext ×1

hosting ×1

interface ×1

mongodb ×1

reflection ×1

wpf ×1