我正在開發一個WPF應用程序使用MVVM模式,我有一個組合框與itemssource綁定viewmodel,我想有一個默認選項中的組合框像「 - 選擇用戶 - 「,這樣做的最佳方法是什麼? 這是我的XAML代碼:如何添加默認組合框「 - 選擇用戶 - 」
<ComboBox Grid.Column="1" HorizontalAlignment="Left" Margin="5.2,8.2,0,7.8" Grid.Row="5" Width="340" ItemsSource="{Binding Path=Users}" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding SelectedUser}" Grid.ColumnSpan="2">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="FirstName"/>
<Binding Path="LastName"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
你是什麼意思讓讓comboboxitem,因爲他們 –
沒有在你的組合框項目列表中的其他項目,只是默認的文本。 – Muds
我很困惑我不明白你是什麼意思 –