2016-07-15 7 views
3

그래서 RadCombobBox에는 옵션 중 하나가 입력 필드가 될 수있는 옵션 목록이 포함되도록 편집되어 있습니다. 선택할 수있는 입력 필드에는 여러 가지 유형이 있지만 정수 입력 필드에 문제가 있습니다. 문제가없는 텍스트 입력 필드가있는 것도 있습니다.RadComboBox 내부를 클릭 할 때 포커스가 잘못되었습니다.

콤보 상자는 다음과 같습니다, 여기에 생각이 사전 설정을 선택할 수 있습니다 미리 설정된 값이 텍스트 옵션 아래에 (그것을 상관하지 않습니다) 네덜란드어 텍스트

enter image description here

입니다

설정 (정수 값에 해당) 또는 사용자 고유의 값을 입력 할 수 있습니다. 그것을 선택하고를 닫

  • 을 내가 (회색으로 표시됩니다) 입력 상자를 클릭하려고하면 : 내가 뭘 (마지막 하나는 매우 독특한입니다) 다른 장소를 클릭 할 때 발생

    콤보 상자 (이것은 내가 원하는)가 아닙니다.

  • 콤보 상자의 오른쪽에있는 화살표를 클릭하면 값이 변경됩니다.
  • 마우스로 스크롤하면 값이 변경됩니다.
  • 입력란에 마우스를 계속 올려 놓으면 실제로 원하는 값을 입력 할 수 있습니다.
  • 먼저 측면의 버튼을 클릭하고 입력 상자 안쪽을 클릭하면 값을 편집 할 수 있습니다.

내가 원하는 것은 입력 상자를 클릭하여 내부 값을 편집 할 수 있고 입력이 끝나면 입력 (또는 콤보 박스 외부)을 눌러 닫을 수 있습니다.

어떻게 든 포커스 또는 뭔가 (나는 100 % 확신하지 못함)가 실패하는 것 같습니다. 여기 는 IntegerDataTemplate의 XAML 코드 :

정수 선택

<Style x:Key="NumericUpDownStyle" TargetType="{x:Type telerik:RadNumericUpDown}"> 
    <Style.Triggers> 
     <Trigger Property="IsEnabled" Value="False"> 
      <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" /> 
     </Trigger> 
     <Trigger Property="IsEditable" Value="False"> 
      <Setter Property="SmallChange" Value="0" /> 
      <Setter Property="LargeChange" Value="0" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

<!-- Integer editor --> 
<DataTemplate x:Key="IntegerDataTemplate"> 
    <telerik:RadNumericUpDown x:Name="NumericUpDown" 
           Width="{Binding Path=ActualWidth, 
               ElementName=Editor}" 
           MaxWidth="{Binding Path=ActualWidth, 
               ElementName=Editor, 
               Converter={StaticResource WidthToWidthConverter}}" 
           HorizontalContentAlignment="Left" 
           Background="Transparent" 
           FontFamily="{telerik:Windows8Resource ResourceKey=FontFamilyStrong}" 
           IsInteger="True" 
           Style="{StaticResource NumericUpDownStyle}" 
           UpdateValueEvent="PropertyChanged" 
           Value="{Binding Path=Value, 
               UpdateSourceTrigger=PropertyChanged, 
               NotifyOnSourceUpdated=True}"> 
     <telerik:RadNumericUpDown.NumberFormatInfo> 
      <globalization:NumberFormatInfo NumberGroupSeparator="" /> 
     </telerik:RadNumericUpDown.NumberFormatInfo> 
    </telerik:RadNumericUpDown> 
</DataTemplate> 

<!-- Integer as Option --> 
<DataTemplate x:Key="OptionsDataTemplate"> 
    <TextBlock Height="20" Text="{Binding Converter={StaticResource IntegerSelectorObjectToStringConverter}}" /> 
</DataTemplate> 

<local:SelectorTypeTemplateSelector x:Key="IntegerTemplateSelector" 
            OptionsDataTemplate="{StaticResource OptionsDataTemplate}" 
            SelectorDataTemplate="{StaticResource IntegerDataTemplate}" /> 

어딘가가 잘못된 것입니다 올바른 방법으로 날 지점 수있는 사람의 주위에 (작품을 것입니다 해결하기 위해이 좋을지라도).

나는 동일한 코드를 가지고 있지만 제대로 작동하는 텍스트 상자를 추가하고 싶습니다. 아래 비교를 위해 코드를 추가했으나 중요한 차이점을 찾을 수 없었습니다. (실제로는 제대로 작동)

텍스트 선택

<Style x:Key="TextBoxStyle" TargetType="{x:Type telerik:RadWatermarkTextBox}"> 
    <Setter Property="BorderBrush" Value="{StaticResource BasicBrush}" /> 
    <Setter Property="FontFamily" Value="{telerik:Windows8Resource ResourceKey=FontFamilyStrong}" /> 
    <Setter Property="Padding" Value="2,2,0,0" /> 
    <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}" /> 
    <Setter Property="telerik:RadWatermarkTextBox.WatermarkTemplate"> 
     <Setter.Value> 
      <DataTemplate> 
       <TextBlock Margin="2,3,0,0" 
          FontFamily="Segoe UI" 
          FontStyle="Italic" 
          Foreground="{StaticResource WaterMarkBrushNoOpacity}" 
          Padding="0,-2,0,0" 
          Text="{Binding}" /> 
      </DataTemplate> 
     </Setter.Value> 
    </Setter> 
    <Style.Triggers> 
     <Trigger Property="IsEnabled" Value="False"> 
      <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" /> 
     </Trigger> 
     <Trigger Property="IsReadOnly" Value="True"> 
      <Setter Property="BorderBrush" Value="{StaticResource MarkerDisabledBrush}" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

<!-- String editor --> 
<DataTemplate x:Key="StringDataTemplate"> 
    <telerik:RadWatermarkTextBox x:Name="WatermarkTextBox" 
           HorizontalAlignment="Stretch" 
           HorizontalContentAlignment="Stretch" 
           VerticalContentAlignment="Top" 
           Background="Transparent" 
           BorderThickness="1" 
           Style="{StaticResource TextBoxStyle}" 
           Text="{Binding Path=Value, 
               UpdateSourceTrigger=PropertyChanged, 
               NotifyOnSourceUpdated=True}" /> 
</DataTemplate> 

<!-- String as Option --> 
<DataTemplate x:Key="OptionsDataTemplate"> 
    <TextBlock Height="20" Text="{Binding Converter={StaticResource StringSelectorObjectToStringConverter}}" /> 
</DataTemplate> 

<local:SelectorTypeTemplateSelector x:Key="StringTemplateSelector" 
            OptionsDataTemplate="{StaticResource OptionsDataTemplate}" 
            SelectorDataTemplate="{StaticResource StringDataTemplate}" /> 

답변

1

이 솔루션은 내가 아래 미리보기 마우스로 해결하기 위해 노력하지만 내가 할 필요하면 추가하여 미리보기 마우스 최대에이었다 오히려 간단했다 다음 :

telerik:RadComboBox x:Name="Editor" 
    BorderThickness="0" 
    FontWeight="SemiBold" 
    ItemTemplateSelector="{StaticResource IntegerTemplateSelector}" 
    PreviewMouseLeftButtonUp="EditorPreviewMouseLeftButtonUp" 
          SelectionBoxTemplate="{StaticResource SelectionboxTemplate}" 
    Validation.ErrorTemplate="{StaticResource ErrorTemplate}" /> 

이 코드 뒤에이 싶 보았다 :

private void EditorPreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) 
{ 
    var originalSource = e.OriginalSource as FrameworkElement; 
    if ((originalSource != null) && (originalSource.ParentOfType<TextBox>() != null)) 
    { 
     e.Handled = true; 
    } 
} 

선택이 변경되면 이는 MouseUp입니다 이벤트가 완료되면 콤보 박스가 닫히지 않습니다. 이벤트가 끝나면 콤보 박스가 닫히지 않습니다. 값을 변경 한 후에 Enter 키를 누르기 만하면됩니다. 그러면 값이 올바르게 선택되고 업데이트됩니다.

1

그것은 (예 RadComboBox 스타일 + 코드), 그러나 그것을 실제로 모든 비트와 조각 주위 하구없이 무슨 일이 일어나고 있는지 정말 어렵다 그것은 특히 표준 WPF ComboBox에 팝업을 여는 FocusedDropDown 상태가있는 경우 포커스를 잃을 때 자동으로 닫히는 드롭 다운과 관련이 있다고 가정하는 것이 자연 스럽습니다.

Telerik에서 스타일을 가져 와서 코드를 새 클래스로 확장하고 가져온 템플릿으로 스타일을 다시 지정하여 RadComboBox를 복사 해 볼 수 있습니다. 이렇게하면 메소드를 재정의하고 이벤트에 첨부 할 수 있습니다 (예 :Got/LostFocus)를 선택하고 템플리트로 주위를 둘러보고 필요에 맞게 조정할 수 있는지 확인하십시오.

템플릿을 다시 스타일화할 수 있기 때문에 이러한 동작을 기존 컨트롤에 포함시키려는 시도는 종종 많은 슬픔 (그리고 시간 낭비)으로 끝납니다.

콤보 상자에 숫자가 위/아래로 삽입 된 NumericRadComboBox를 만드는 것이 쉬울 것이라고 생각했습니다. 따라서 드롭 다운 화살표 옆에 숫자 위/아래 버튼이 있도록 RadComboBox 스타일을 변경하고 수동으로 증분/감소 동작을 구현합니다. PreviewMouseLeftButtonUp="EditorPreviewMouseLeftButtonUp"을 같이 RadComboBox 코드를 만든 XAML에서 :

enter image description here

관련 문제