私はTextPropertyがバインドされているのに何も起こらないので、GetBindingExpression(...)を使用する前に既に試しました。UpdateTarget()この関数は、レイアウトが更新された後にのみ有効です。その結果、
/// <summary>
/// Prevents the selection of an item and displays the result of the TextProperty-Binding
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SeveritiesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox box = sender as ComboBox;
if (box == null)
return;
if (box.SelectedItem != null)
{
box.SelectedItem = null;
EventHandler layoutUpdated = null;
layoutUpdated = new EventHandler((o, ev) =>
{
box.GetBindingExpression(ComboBox.TextProperty).UpdateTarget();
box.LayoutUpdated -= layoutUpdated;
});
box.LayoutUpdated += layoutUpdated;
}
}
私がコンボボックスを使用する理由は、私がそれを使用しているこのエリアにあまり置かれていないということです。 itemcontrolを使用すると、チェックボックスを "ポップアップ"する機能はありません。エキスパンダーを使用することも満足のいくものではありません。 – SACO
選択スタイルの外観を変更することができます。 [この質問]を確認してください(http://stackoverflow.com/questions/3829315/stop-highlighting-selected-item-wpf-combobox) – WaltiD
お返事ありがとうございます。私は別の解決策を見つけた... – SACO