当放置在主窗口上时,用户控件缺少按钮

时间:2019-07-03 07:02:11

标签: c# wpf

我有一个由2列(在网格中)组成的主窗口,在左侧有一个地图(Microsoft Bing),在右侧我想创建某种配置面板。

我创建了一个UserControl,旨在显示一些统计信息并配置功能

This是用户控件的外观,This是我运行程序时的外观。如您所见,顶部缺少标签,按钮和文本框。

这是用户控件的代码:

<UserControl x:Class="WEI.UserControls.MapTab"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WEI.UserControls"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="300" >
    <Grid Background="AliceBlue">
        <TabControl Margin="5" BorderBrush="Gainsboro">
            <TabControl.Resources>
                <Style TargetType="TabItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="TabItem">
                                <Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="Gainsboro" CornerRadius="4,4,0,0" Margin="2,0">
                                    <ContentPresenter x:Name="ContentSite"
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Center"
                                        ContentSource="Header"
                                        Margin="10,2"/>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter TargetName="Border" Property="Background" Value="LightSkyBlue" />
                                    </Trigger>
                                    <Trigger Property="IsSelected" Value="False">
                                        <Setter TargetName="Border" Property="Background" Value="GhostWhite" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>
            <TabItem Header="General">
                <Grid>

                    <Button Margin="82,126,95,392" x:Name="setCoordinates" Content="Go to coordinate" FontSize="10" />
                    <Button Margin="82,190,95,328" x:Name="addMark" Content="Add mark" FontSize="10" />

                    <TextBox x:Name="Latitude" Margin="41,52,173,479"/>
                    <TextBox x:Name="Longitude" Margin="161,53,54,478"/>
                    <Label Content="Latitude" Margin="41,18,173,513" />
                    <Label Content="Longitude" Margin="160,17,54,513" />
                    <Separator/>

                    <Border BorderBrush="AliceBlue" BorderThickness="1"  Margin="88,348,95,83">
                        <TextBlock  TextWrapping="Wrap"  Margin="-1" Text="" VerticalAlignment="Center" Height="130"  />
                    </Border>
                    <Label Content="Active targets" HorizontalAlignment="Left" Margin="96,299,0,0" VerticalAlignment="Top"/>
                </Grid>
            </TabItem>
            <TabItem Header="Statistics" >

            </TabItem>
            <TabItem Header="Details" />

        </TabControl>
    </Grid>
</UserControl>

0 个答案:

没有答案