2017-11-27 14 views
1

私は、カスタムComboBoxを使用してWindowsアプリケーションを持っています。私のマシンでは、テキストが正しく表示されます。しかし、他のマシンでは、これはちょっと切っています。何か提案してください?WPF Comboboxが異なるマシンで異なる表示

<ComboBox Width="140" Height="5" 
        ItemsSource="{Binding SecurityContexts, Mode=OneWay}" 
        SelectedItem="{Binding ActiveSecurityContext, Mode=TwoWay}" 
        ToolTip="Working Location"> 
    <ComboBox.ItemTemplate> 
     <DataTemplate> 
      <!--<TextBlock Text="{Binding Location}"/>--> 
      <TextBlock Height="27"> 
       <TextBlock.Text> 
        <MultiBinding StringFormat="{}{0}&#x0a;{1}"> 
        <Binding Path="AddBlank" FallbackValue=''/> <!--Just to add a blank field to hide the location details--> 
        <Binding Path="Location" /> 
        </MultiBinding> 
       </TextBlock.Text> 
      </TextBlock> 
     </DataTemplate> 
    </ComboBox.ItemTemplate> 
</ComboBox> 
+1

高さ= "5"?それを十分大きくしてみてください。異なるマシンでは異なるフォント設定が使用され、異なるバージョンのWindowsでは異なるデフォルトのコントロールテンプレートが使用されます。通常のバリエーションを許可する。ユーザーがばかばかしいバリエーションに夢中なら、それはあなたの問題ではありません。 –

+0

ありがとうEd Plunkett – newbee

答えて

1

あなたのコントロールのハードコードの高さと幅を強く推奨しません。 WPFが提供する幅広いコンテナを使用する方法を学ぶ方がはるかに優れた方法です。特に、Gridが最も基本的ですが、私の意見では最も強力です。これは、proportionalAutoサイズの行と列を定義できるためです。これにより、サイズ変更可能なアプリケーションを作成することによって、宛先モニタの解像度に関する懸念を取り除くことができます。

あなたの場合は、コメントに記載されているとおり、身長が小さすぎる可能性があります。グリッドを定義してコンボボックスを配置することができます。

<Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="5*"/> 
     </Grid.ColumnDefinitions> 
     <ComboBox Grid.Row="0" Grid.Column="0" 
       ItemsSource="{Binding SecurityContexts, Mode=OneWay}" 
       SelectedItem="{Binding ActiveSecurityContext, Mode=TwoWay}" 
       ToolTip="Working Location"> 
      <ComboBox.ItemTemplate> 
       <DataTemplate> 
        <!--<TextBlock Text="{Binding Location}"/>--> 
        <TextBlock Height="27"> 
         <TextBlock.Text> 
          <MultiBinding StringFormat="{}{0}&#x0a;{1}"> 
           <Binding Path="AddBlank" FallbackValue=''/> 
           <!--Just to add a blank field to hide the location details--> 
           <Binding Path="Location" /> 
          </MultiBinding> 
         </TextBlock.Text> 
        </TextBlock> 
       </DataTemplate> 
      </ComboBox.ItemTemplate> 
     </ComboBox> 
    </Grid> 
+0

ありがとうDaniele – newbee

関連する問題