当我最大化我的应用程序并尝试设置焦点或点击某些文本框或组合框我无法做到。将鼠标放在这些物体上多次后,我有时会找到一个让我点击的完美点。任何想法可能导致这个或如何解决它。
XAML Snipit:
Window x:Class="qaTrackingDatabase.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="QA Tracking DB Update Tool" Height="715.963" MinHeight="715.983" Width="868.283" MinWidth="878.283" Icon="rm12icon.ico" VerticalAlignment="Top">
<Grid Margin="0,0,-8,3">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFDFEDF7" Offset="0"/>
<GradientStop Color="#FFDFECF7" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TabControl Name="myTabControl" Margin="0" SelectionChanged="TabControl_SelectionChanged" Background="#FFDFECF7">
<TabItem x:Name="Branch" Header="Branch" MinWidth="170" MinHeight="25">
<Border BorderBrush="Black" BorderThickness="1" MaxHeight="238" Margin="10" VerticalAlignment="Top">
<Grid>
<RadioButton Name="Add" Content="Add" Margin="25,28,0,150" Checked="Branch_RadioBtns_Checked" HorizontalAlignment="Left" Width="619"/>
<RadioButton Name="Delete" Content="Delete" Margin="25,99,202,84" Checked="Branch_RadioBtns_Checked" />
<TextBox Name="Add_Name_txtBox" IsEnabled="{Binding ElementName=Add, Path=IsChecked}" Height="25" TextWrapping="Wrap" Text="Enter Name" Width="230" Margin="352,53,264,0" SpellCheck.IsEnabled="True" Background="White" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="250,57,490,158"> Branch Name:</TextBlock>
<ComboBox Name="Dproduct_Combo" IsEnabled="{Binding ElementName=Delete, Path=IsChecked}" Text="Select" HorizontalAlignment="Left" Height="25" Margin="111,120,0,0" VerticalAlignment="Top" Width="119" IsReadOnly="True" SelectionChanged="Get_Dproduct_Branch"/>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="41,123,740,92"> Product:</TextBlock>
<ComboBox Name="Aproduct_Combo" IsEnabled="{Binding ElementName=Add, Path=IsChecked}" Text="Select" HorizontalAlignment="Left" Height="25" Margin="111,53,0,0" VerticalAlignment="Top" Width="119"/>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="41,57,740,150"> Product:</TextBlock>
<TextBlock TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" Margin="250,123,490,91"> Select Branch:</TextBlock>
<ComboBox Name="Dbranch_Combo" IsEnabled="{Binding ElementName=Delete, Path=IsChecked}" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="119" IsReadOnly="True" Margin="351,119,0,0"/>
<Button Content="Commit
Changes" FontFamily="Levenim MT" FontWeight="Bold" FontSize="16" Click="Branch_Commit_Changes" Margin="637,177,10,10" MaxHeight="49" MaxWidth="189" MinHeight="49" MinWidth="189" HorizontalAlignment="Left"/>
</Grid>
</Border>
</TabItem>
答案 0 :(得分:0)
您的保证金/高度/宽度值会发生一些非常奇怪的事情。我强烈建议您开始使用网格行和列。从长远来看,你会发现当你这么做时,一切都会在XAML中调整大小并运行得更好。
以下是窗口中标签控件的更新。
<TabControl Name="myTabControl" Margin="0" SelectionChanged="TabControl_SelectionChanged" Background="#FFDFECF7">
<TabItem x:Name="Branch" Header="Branch" MinWidth="170" MinHeight="25">
<Border BorderBrush="Black" BorderThickness="1" Margin="10" VerticalAlignment="Top">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<RadioButton Grid.Row="0" Margin="5" Name="Add" Content="Add" />
<TextBlock Grid.Row="1" Grid.Column="0" Margin="5" TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" > Product:</TextBlock>
<ComboBox Grid.Row="1" Grid.Column="1" Margin="5" Name="Aproduct_Combo" IsEnabled="{Binding ElementName=Add, Path=IsChecked}" Text="Select" Width="119"/>
<TextBlock Grid.Row="1" Grid.Column="2" Margin="5" TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" > Branch Name:</TextBlock>
<TextBox Grid.Row="1" Grid.Column="3" Margin="5" Name="Add_Name_txtBox" IsEnabled="{Binding ElementName=Add, Path=IsChecked}" TextWrapping="Wrap" Text="Enter Name" Width="230" SpellCheck.IsEnabled="True" Background="White" />
<RadioButton Grid.Row="2" Margin="5" Name="Delete" Content="Delete" />
<TextBlock Grid.Row="3" Grid.Column="0" Margin="5" TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" > Product:</TextBlock>
<ComboBox Grid.Row="3" Grid.Column="1" Margin="5" Name="Dproduct_Combo" IsEnabled="{Binding ElementName=Delete, Path=IsChecked}" Text="Select" Width="119" IsReadOnly="True" />
<TextBlock Grid.Row="3" Grid.Column="2" Margin="5" TextDecorations="Underline" FontWeight="Bold" FontFamily="Levenim MT" > Select Branch:</TextBlock>
<ComboBox Grid.Row="3" Grid.Column="3" Margin="5" Name="Dbranch_Combo" IsEnabled="{Binding ElementName=Delete, Path=IsChecked}" IsReadOnly="True" />
<Button Grid.Row="4" Grid.Column="4" Margin="5" Content="Commit
Changes" FontFamily="Levenim MT" FontWeight="Bold" FontSize="16" />
</Grid>
</Border>
</TabItem>
</TabControl>