请考虑以下示例:
interface IBase1
{
int Percentage { get; set; }
}
interface IBase2
{
int Percentage { get; set; }
}
interface IAllYourBase : IBase1, IBase2
{
}
class AllYourBase : IAllYourBase
{
int percentage;
int Percentage {
get { return percentage; }
set { percentage = value; }
}
}
void Foo()
{
IAllYourBase iayb = new AllYourBase();
int percentage = iayb.Percentage; // Fails to compile. Ambiguity between 'Percentage' property.
}
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,Percentage要调用的属性之间存在歧义.假设IBase1和IBase2接口可能没有 …
我创造了以下事件ListBox:
<ListBox x:Name="RecentItemsListBox" Grid.Row="1" BorderThickness="0" Margin="2,0,0,0" SelectionChanged="RecentItemsListBox_SelectionChanged">
<ListBox.Resources>
<Style TargetType="{x:Type ListBoxItem}"
BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Style.Triggers>
<!--This trigger is needed, because RelativeSource binding can only succeeds if the current ListBoxItem is already connected to its visual parent-->
<Trigger Property="IsVisible" Value="True">
<Setter Property="HorizontalContentAlignment"
Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment"
Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,2,0,0">
<TextBlock Text="{Binding Number}" />
<StackPanel Orientation="Vertical" Margin="7,0,0,0">
<TextBlock Text="{Binding File}" />
<TextBlock Text="{Binding Dir}" …Run Code Online (Sandbox Code Playgroud) 我有一个WPF窗口,其中包含一个WindowsFormsHost元素.我需要在这个元素之上绘制东西,但是WindowsFormsHost它的本质意味着它始终位于绘图堆的顶部.由于我无法在WindowsFormsHost组件顶部的同一个WPF窗口中绘制,我可以在其上覆盖另一个窗口吗?
我已经初步尝试了这个,但是我遇到了一些问题:
1)我无法阻止主窗口和覆盖窗口之间的其他应用程序的窗口.
2)当我按Alt-Tab时,覆盖窗口出现在窗口列表中,这非常难看.
基本上我需要一个"子窗口"的概念,并且所有意图和目的的窗口都显示为另一个窗口的一部分.UserControls对我来说不起作用,因为它总是WindowsFormsHost会在它上面绘制.
有任何想法吗?
更新[2011年5月23日10:13]
谢谢你们的回答.
我已经尝试过这种ChildWindow方法,而且WindowsFormsHost元素仍然是最重要的.据我了解,只有一个真正的窗口可以在a上面绘制WindowsFormsHost,同一个窗口中的任何东西都会在下面WindowsFormsHost.
用的元素WindowsFormsHost仍然会在一个WinForms组件画,他们总是画在上面,这似乎非流通...
我想我正在寻找的是一种方法来停靠外部窗口作为主窗口的一部分.在Mac上,有一个真正的"儿童窗口"的概念,我正在寻找类似的东西.
我已经使用outerHeight,并outerWidth在许多地方.现在,在jQuery 1.8发布之后,我遇到了很多由对象返回而不是它的大小引起的问题.
例如:
$('#stackoverflowdiv').Height() // returns 100 px
$('#stackoverflowdiv').outerHeight() // returns "stackoverflowdiv" div
Run Code Online (Sandbox Code Playgroud)
我发现解决这个问题的唯一方法是在函数中使用"true/false",如下所示,但我得到的结果与标准width()和height()函数相同:
$('#stackoverflowdiv').outerHeight(true) // returns 100 px
$('#stackoverflowdiv').outerHeight(false) // returns 100 px
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么这不再工作或以其他方式获得元素的高度/宽度+其边距.
编辑:我开始相信这是因为我使用contents()函数在iframe中选择元素.我会尝试做一个演示.
我们可以在WPF中调试Xaml吗?有没有可以做到这一点的外部工具或VS插件?
我有一个WPF应用程序ListBox.拖动机制已经实现,但是当列表太长并且我想将项目移动到不可见的位置时我不能.
例如,屏幕显示10个项目.我有20件物品.如果我想将最后一项拖到第一个位置,我必须拖到顶部并放下.向上滚动并再次拖动.
如何进行ListBox自动滚动?
这个问题的灵感来自这个封闭的问题:
我已经在企业应用程序中实现了自己的自定义MVVM实现.我有兴趣知道:
我希望这个问题不是主观的,每个人请不要参与:)
我有一个问题绑定DataTable到a DataGrid.我已经搜索过解决方案但是无法摆脱错误.使用WindowsForms时绑定工作正常,所以这DataTable是正确的.我只是不能将它绑定到WPF-DataGrid.
错误消息:未处理AmbiguousMatchException
源:mscorlib
我已经设置了新项目来摆脱任何不良链接等.
XAML的代码:
<DataGrid x:Name="grid1" Margin="10" ItemsSource="{Binding}"
AutoGenerateColumns="True"></DataGrid>
Run Code Online (Sandbox Code Playgroud)
我已经尝试过跟随C#-Code了:
grid1.ItemsSource = dt.DefaultView;
Run Code Online (Sandbox Code Playgroud)
要么
grid1.DataContext = dt.DefaultView;
Run Code Online (Sandbox Code Playgroud)
要么
grid1.DataContext = dtex;
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
在WPF中,您可以将其设置为TargetType类型的名称,也可以将其设置为{x:Type nameOfType}.
有谁知道有什么区别?