第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

WPF 無法在 ComboBox 中選擇啟用的項目

WPF 無法在 ComboBox 中選擇啟用的項目

PHP
楊魅力 2022-11-13 13:41:31
我正在嘗試創(chuàng)建一個組合框,其中啟用了選擇列表中的某些項目而禁用了其他項目。在視覺上,我能夠做到這一點,但是當(dāng)我選擇一個視覺上啟用的項目時,什么也沒有發(fā)生。XAML:<ComboBox ItemsSource="{Binding EndpointModel.DisplayFormat}"           VerticalAlignment="Center" Margin="0,0,10,0"           SelectedItem="{Binding EndpointModel.SelectMediaFormat}">     <ComboBox.ItemContainerStyle>          <Style TargetType="ComboBoxItem">              <Setter Property="IsEnabled" Value="{Binding IsEnabled}" />          </Style>     </ComboBox.ItemContainerStyle>     <ComboBox.ItemTemplate>          <DataTemplate>              <ComboBoxItem>                 <TextBlock Text="{Binding Name}" />              </ComboBoxItem>          </DataTemplate>     </ComboBox.ItemTemplate></ComboBox>當(dāng)我單擊上面的選定項目時,什么也沒有發(fā)生 - EndpointModel.SelectMediaFormat 沒有執(zhí)行。刪除ComboBox.ItemTemplate節(jié)的那一刻,我可以成功選擇任何啟用的項目,即<ComboBox ItemsSource="{Binding EndpointModel.DisplayFormat}"           VerticalAlignment="Center" Margin="0,0,10,0"           SelectedItem="{Binding EndpointModel.SelectMediaFormat}">     <ComboBox.ItemContainerStyle>          <Style TargetType="ComboBoxItem">              <Setter Property="IsEnabled" Value="{Binding IsEnabled}" />          </Style>     </ComboBox.ItemContainerStyle></ComboBox>如您所見,我正在顯示對象引用。我不知道如何用實際名稱替換上面的內(nèi)容。正如您想象的那樣,我在 WPF 還很陌生 :-)任何建議,將不勝感激。
查看完整描述

1 回答

?
慕勒3428872

TA貢獻(xiàn)1848條經(jīng)驗 獲得超6個贊

嘗試使用該DisplayMemberPath屬性Name(您要顯示的屬性)。


<ComboBox ItemsSource="{Binding EndpointModel.DisplayFormat}" 

          VerticalAlignment="Center" Margin="0,0,10,0" 

          SelectedItem="{Binding EndpointModel.SelectMediaFormat}"

          DisplayMemberPath="Name">

     <ComboBox.ItemContainerStyle>

          <Style TargetType="ComboBoxItem">

              <Setter Property="IsEnabled" Value="{Binding IsEnabled}" />

          </Style>

     </ComboBox.ItemContainerStyle>

</ComboBox>


查看完整回答
反對 回復(fù) 2022-11-13
  • 1 回答
  • 0 關(guān)注
  • 180 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號