我试图在一个非常简单的WPF应用程序中使用浏览器控件,看来当浏览器加载我请求的页面时(我可以鼠标悬停图像并看到ALT标签),我实际上看不到任何其他内容:

这是应用程序的XAML:
<Window x:Class="SmokeyBox2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SmokeyBox" Height="120" Width="510" ShowInTaskbar="False"
SizeToContent="WidthAndHeight" WindowStyle="None" AllowsTransparency="True"
MouseLeftButtonDown="Window_MouseLeftButtonDown">
<Border Background="#50FFFFFF" CornerRadius="5" BorderThickness="2,0,2,2"
Padding="5 1 5 5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Background="Transparent" Content="SmokeyBox"
MouseLeftButtonDown="Label_MouseLeftButtonDown" />
<TextBox Grid.Row="1" Grid.Column="0" Name="searchText" Width="450" FontFamily="Arial" Foreground="DarkGray"
Background="Transparent" FontSize="20" MouseLeftButtonDown="searchText_MouseLeftButtonDown"
BorderBrush="Transparent" />
<Expander Grid.Row="1" Grid.Column="1" Padding="2 3 0 0 " Expanded="Expander_Expanded"
Collapsed="Expander_Collapsed" />
<WebBrowser Grid.Row="2" Grid.Column="0" x:Name="browser" Visibility="Visible"
Width="480" Height="480" Margin="2 2 2 2" ></WebBrowser>
</Grid> …Run Code Online (Sandbox Code Playgroud) 我有以下代码隐藏:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
ObservableCollection<int> sampleData = new ObservableCollection<int>();
public ObservableCollection<int> SampleData
{
get
{
if (sampleData.Count <= 0)
{
sampleData.Add(1);
sampleData.Add(2);
sampleData.Add(3);
sampleData.Add(4);
}
return sampleData;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的xaml是:
<Window x:Class="Sandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ListBox ItemsSource="{Binding Path=SampleData}"/>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
该列表不显示集合中的值(或任何内容).有人能指出我的错误是什么吗?
我是否需要显式设置DataContext?我想如果没有设置控件将只使用自己作为DataContext.
如何创建Border可以容纳其他UI元素的循环?
像这样的东西:

是否有一些简单的方法来实现类似的效果?
我需要在WPF中引入自定义控件.
伪代码
OnMouseDown()
{
if (this.parent != null)
this.parent.BringToFront(this);
}
Run Code Online (Sandbox Code Playgroud)
我知道,我知道有一个ZIndex,但仍然不明白如何将简单的WinForm替换BringToFront为parent.SetZIndex(this, ?MaxZIndex(parent)? + 1)?
也许有更好的方法在像WPF这样的酷事中做到这一点?!..
有没有一种简单的方法来自定义WPF TabControl,以便它支持TabItem拖放 - 类似于IE和Firefox所做的.
以下示例中的标签(WPF/XAML)只是在屏幕上游行,不会发生包装.删除方向有效,但不提供所需的功能/外观.任何想法如何使WrapPanel包装到当前的大小StackPanel?
<Window Height="300" Width="600">
<StackPanel Orientation="Horizontal">
<WrapPanel>
<Label Height="28" Name="label1" Width="120">First Name</Label>
<Label Height="28" Name="label2" Width="120">John</Label>
<Label Height="28" Name="label3" Width="120">Last Name</Label>
<Label Height="28" Name="label4" Width="120">Smith</Label>
<!-- ...more labels!... -->
</WrapPanel>
<!-- ...other controls/panels... -->
</StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud) 我有一个包含TreeView的HeaderedContentControl.
<HeaderedContentControl Header="Steps" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TreeView Name="WizardSteps" ItemsSource="{Binding WizardSteps}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<!-- Hierarchical data templates here -->
</TreeView>
</HeaderedContentControl>
Run Code Online (Sandbox Code Playgroud)
虽然HeaderedContentControl伸展以填充其父网格内的区域,但我的TreeView控件仅占用可用空间的一小部分.
如何扩展我的TreeView以填充HeaderedContentControl的内容区域?
如您所知,StringFormat对于WPF中的数据表示非常重要.我的问题是如何在WPF中进行多重绑定时使用StringFormat?
如果我举一个非常简单的例子:
我们有变量,它们是A和B,其值为10.255555和25.6999999
我们想要展示它们10.2,25.6吗?
我怎么能用multibinding做到这一点?通常,它与ValueConverter一块蛋糕
任何有关此主题的帮助和想法都将受到高度赞赏
我需要一个可以使用鼠标调整尺寸的拇指控件.当用户将鼠标悬停在其中一个端点上时,应显示一个大小的光标,当用户单击并拖动控件的末尾时,它将被重新调整大小.
我开始认为我应该创建一个由三个拇指控件创建的自定义控件.会有一个主拇指,然后每个端都有一个可以处理重新调整大小的拇指,但我认为这不是一个好的解决方案.
我认为更好的方法是使用单个Thumb控件,然后在鼠标悬停的控件的末尾有一个重新调整大小的Adorner弹出窗口.使用这种方法,您如何检测鼠标悬停在控件的特定区域?将非常感谢如何执行此操作或任何帮助的示例.
wpf ×10
wpf-controls ×10
.net ×2
binding ×2
xaml ×2
border ×1
c# ×1
layout ×1
stackpanel ×1
tabcontrol ×1
treeview ×1
wrappanel ×1