我已经启动了catel:焦点行为将焦点设置在视图的第一项上,这在基本控件上工作正常但在我开发的自定义上没有效果
这是我的代码
主要控制
<views:PortfolioChooserControl x:Name="PortfolioChooserView" DataContext="{Binding PortfolioModel}" Grid.Row="1" Grid.Column="1"
LoadDefaultValue="False" AllowNull="False" HorizontalAlignment="Stretch" Margin="5,0,5,0" Height="25" Focusable="True">
<i:Interaction.Behaviors>
<catel:Focus FocusDelay="400"/>
</i:Interaction.Behaviors>
</views:PortfolioChooserControl>
这里是自定义用户控件
<catel:UserControl x:Class="xxx.Client.WPF.Controls.Portfolio.Views.PortfolioChooserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:catel="http://catel.codeplex.com"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:behaviors1="clr-namespace:xxx.Client.WPF.Core.Behaviors;assembly=IF.Tesoreria.Client.WPF.Core"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:porfolio="clr-namespace:xxx.Client.WPF.Core.DraggingItems.Porfolio;assembly=IF.Tesoreria.Client.WPF.Core"
CloseViewModelOnUnloaded="False">
<catel:UserControl.Resources>
<behaviors1:PortfolioFilteringBehavior x:Key="PortfolioFilteringBehavior"/>
<DataTemplate x:Key="PortfolioSearchTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Ap_Desc}" FontWeight="SemiBold" />
</StackPanel>
</DataTemplate>
</catel:UserControl.Resources>
<AdornerDecorator>
<telerik:RadAutoCompleteBox
x:Name="PortfolioCompleteBox"
TextSearchMode="Contains"
AutoCompleteMode="Suggest"
SelectionMode="Single"
DisplayMemberPath="Ap_Desc"
SelectedItem="{Binding SelectedItem, Mode=TwoWay, ValidatesOnDataErrors=True}"
SearchText="{Binding SearchTextPortfolio, Mode=TwoWay}"
ItemsSource="{Binding PortfolioList}"
HorizontalAlignment="Stretch"
FilteringBehavior="{StaticResource PortfolioFilteringBehavior}"
DropDownItemTemplate="{StaticResource PortfolioSearchTemplate}"
AllowDrop="True">
<i:Interaction.Behaviors>
<porfolio:PortfolioDropperBehavior></porfolio:PortfolioDropperBehavior>
<!--<catel:Focus FocusDelay="400" />-->
</i:Interaction.Behaviors>
</telerik:RadAutoCompleteBox>
</AdornerDecorator>
如果我将行为放在自定义控件中(您看到它已注释)它可以正常工作,但是当我在视图中使用2个投资组合时这会导致问题,因为它会关注最后一个......
我该如何解决这个问题? 提前致谢
答案 0 :(得分:0)
您的PortfolioChooserControl可能有一个容器网格,也可以检索焦点。确保禁用在不应该获得任何焦点的每个容器上检索焦点。