<wfi:WindowsFormsHost> <ElementHost> <ScrollViewer Name="scrollViewer" Grid.Row="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" PreviewMouseDown="scrollViewer_PreviewMouseDown"> <ScrollViewer.Resources> <Style TargetType="Label"> <Setter Property="Height" Value="24"></Setter> <Setter Property="Width" Value="75"></Setter> <Setter Property="Margin" Value="0 1"></Setter> <Setter Property="HorizontalContentAlignment" Value="Right"></Setter> <Setter Property="VerticalContentAlignment" Value="Center"></Setter> </Style> <Style TargetType="ComboBox"> <Setter Property="Width" Value="90"></Setter> <Setter Property="Height" Value="22"></Setter> <Setter Property="VerticalAlignment" Value="Center"></Setter> <Setter Property="VerticalContentAlignment" Value="Center"></Setter> </Style> </ScrollViewer.Resources> <StackPanel Grid.Row="0" Margin="20 0" MinWidth="470"> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource ConditionOrderEdit_Explanation}" VerticalAlignment="Top"></Label> <TextBlock Name="txtExplanation" TextWrapping="Wrap" Padding="0 5 5 0" MaxWidth="390"></TextBlock> </StackPanel> <Border BorderBrush="Gray" BorderThickness="0 1 0 0" Margin="0 3"></Border> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource Pub_ContractNoColon}"></Label> <ComboBox Name="cmbContract" Width="120" SelectionChanged="cmbContract_SelectionChanged"></ComboBox> </StackPanel> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource ConditionOrderEdit_TriggerCondition}" VerticalAlignment="Top"></Label> <StackPanel> <StackPanel Orientation="Horizontal" Margin="0 3" Height="22"> <RadioButton Name="radConditionTypePrice" Content="{DynamicResource ConditionOrderEdit_When}" GroupName="ConditionType" VerticalAlignment="Center" IsChecked="True" Margin="0 0 5 0" Checked="radConditionType_Checked"></RadioButton> <StackPanel Name="conditionTypePriceSettingPanel" Orientation="Horizontal"> <ComboBox Name="cmbComparePriceType" VerticalAlignment="Center" IsReadOnly="True" IsEditable="True"></ComboBox> <ComboBox Name="cmbCompareFlag" VerticalAlignment="Center" Width="45" Height="22" Margin="5 0" IsReadOnly="True" IsEditable="True" Padding="8 0 0 0" VerticalContentAlignment="Center" FontSize="16" FontFamily="新宋体"></ComboBox> <CustomUi:UpDownNumberText x:Name="txtComparePriceValue" MinValue="0" MaxValue="10000000" InputMaxValue="999999999" DecimalPlaces="2" Width="90" Height="22"></CustomUi:UpDownNumberText> </StackPanel> <TextBlock Text="{DynamicResource ConditionOrderEdit_Trigger}" Margin="5 0 0 0" VerticalAlignment="Center"></TextBlock> </StackPanel> <StackPanel Orientation="Horizontal" Margin="0 3" Height="22"> <RadioButton Name="radConditionTypeTime" Content="{DynamicResource ConditionOrderEdit_TimeArrival}" GroupName="ConditionType" VerticalAlignment="Center" Margin="0 0 5 0" Checked="radConditionType_Checked"></RadioButton> <wfi:WindowsFormsHost Width="80"> <wf:DateTimePicker x:Name="dtTriggerTime" Format="Time" ShowUpDown="True" Enabled="False"></wf:DateTimePicker> </wfi:WindowsFormsHost> <TextBlock Text="{DynamicResource ConditionOrderEdit_Trigger}" Margin="5 0 0 0" VerticalAlignment="Center"></TextBlock> </StackPanel> <StackPanel Orientation="Horizontal" Margin="0 3" Height="22"> <RadioButton Name="radConditionTypeOpen" Content="{DynamicResource ConditionOrderEdit_OpenTrigger}" GroupName="ConditionType" VerticalAlignment="Center" Margin="0 0 5 0" Checked="radConditionType_Checked"></RadioButton> </StackPanel> </StackPanel> </StackPanel> <Border BorderBrush="Gray" BorderThickness="0 1 0 0" Margin="0 4 0 5"></Border> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource Pub_BuyOrSellColon}"></Label> <RadioButton Name="radBuy" GroupName="BuyOrSell" Content="{DynamicResource Pub_BuyIn}" VerticalAlignment="Center" IsChecked="True" Margin="0 0 15 0"></RadioButton> <RadioButton Name="radSell" GroupName="BuyOrSell" Content="{DynamicResource Pub_SellOut}" VerticalAlignment="Center"></RadioButton> </StackPanel> <StackPanel Orientation="Horizontal" Name="panelOffsetFlag"> <Label Content="{DynamicResource Pub_OpenOrCloseColon}"></Label> <RadioButton Name="radOffsetFlagOpen" GroupName="OffsetFlag" Content="{DynamicResource Type_Open}" VerticalAlignment="Center" IsChecked="True" Margin="0 0 15 0"></RadioButton> <RadioButton Name="radOffsetFlagCloseToday" GroupName="OffsetFlag" Content="{DynamicResource Type_CloseToday}" VerticalAlignment="Center" Margin="0 0 15 0"></RadioButton> <RadioButton Name="radOffsetFlagClose" GroupName="OffsetFlag" Content="{DynamicResource Type_Close}" VerticalAlignment="Center"></RadioButton> </StackPanel> <StackPanel Orientation="Horizontal" Name="panelIsDeposit"> <Label Content="{DynamicResource ConditionOrderEdit_GuaranteeType}"></Label> <ComboBox Name="cmbIsDeposit"></ComboBox> </StackPanel> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource ConditionOrderEdit_Price}"></Label> <ComboBox Name="cmbOrderType" SelectionChanged="cmbOrderType_SelectionChanged"></ComboBox> <CustomUi:UpDownNumberText x:Name="txtOrderPrice" MinValue="0" MaxValue="10000000" InputMaxValue="999999999" DecimalPlaces="2" Width="90" Height="22" Margin="5 0 0 0"></CustomUi:UpDownNumberText> </StackPanel> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource ConditionOrderEdit_FloatPrice}"></Label> <CustomUi:UpDownNumberText x:Name="txtFloatPrice" MinValue="-10000" MaxValue="10000" DecimalPlaces="0" Increment="1" Width="90" Height="22"></CustomUi:UpDownNumberText> </StackPanel> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource ConditionOrderEdit_OrderQtt}"></Label> <CustomUi:UpDownNumberText x:Name="txtOrderQtt" MinValue="0" MaxValue="1000000000" InputMaxValue="999999999" DecimalPlaces="0" Width="90" Height="22"></CustomUi:UpDownNumberText> </StackPanel> <StackPanel Orientation="Horizontal"> <Label Content="{DynamicResource ConditionOrderEdit_ValidDate}"></Label> <ComboBox Name="cmbValidDate" SelectionChanged="cmbValidDate_SelectionChanged"></ComboBox> <DatePicker Name="dpValidDate" VerticalAlignment="Center" VerticalContentAlignment="Center" Padding="2 1 1 1" Height="22" Width="110" Margin="3 0 0 0"></DatePicker> </StackPanel> </StackPanel> </ScrollViewer> </ElementHost> </wfi:WindowsFormsHost>
添加鼠标点击
<ScrollViewer Name="scrollViewer" Grid.Row="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" PreviewMouseDown="scrollViewer_PreviewMouseDown">
2设置焦点
private void scrollViewer_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (Mgr.CurrFocusIn != Constant.FocusInTrade) { this.Focus(); Mgr.CurrFocusIn = Constant.FocusInTrade; } }