我正在尝试使用WPF / XAML,我对可用的控件有基本的了解。我还不明白的是如何将它们结合起来。 为了实践这一点,我试图复制以下控件:
我设计的组件如下所示:
这就是编码:
<Window x:Class="Uranus.View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="469" Width="750">
<Window.Resources>
<Style x:Key="Flat">
<Setter Property="Control.Background" Value="{x:Null}" />
<Setter Property="Control.BorderBrush" Value="{x:Null}" />
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.Background" Value="{x:Null}" />
<Setter Property="Control.BorderBrush" Value="{x:Null}" />
<Setter Property="Control.FontWeight" Value="Bold" />
</Trigger>
<Trigger Property="Control.IsFocused" Value="True">
<Setter Property="Control.FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<!-- -->
<Rectangle Fill="LightBlue" Margin="277,21,160,346"/>
<!-- -->
<TextBox Height="30" HorizontalAlignment="Left" Margin="277,113,0,0" Name="textBox1" VerticalAlignment="Top" Width="272" />
<!-- -->
<Image Source="..\Pictures\Suchlupe.jpg" Margin="309,171,391,231" ></Image>
<!-- -->
<TextBox Height="23" HorizontalAlignment="Left" Margin="374,176,0,0" Name="textBoxSucheTabelle" VerticalAlignment="Top" Width="120" Foreground ="LightGray" Text="Nachricht suchen"/>
<!-- -->
<Button Name="buttonSuchpfeil" Style="{StaticResource Flat}" Margin="509,171,197,232">
<StackPanel>
<Image Source="..\Pictures\Suchpfeil.jpg"></Image>
</StackPanel>
</Button>
</Grid>
</Window>
我的问题是:如何将我的控件组合在示例中?我真的想了解更多有关WPF的信息!
感谢您的帮助!
答案 0 :(得分:1)
有很多资源可以帮助理解XAML,特别是对于WPF。我建议以下内容了解更多信息: