如何禁用 RadmulticolumnCombobox WPF 中的项目?
How can I disable an item in RadmulticolumnCombobox WPF?
我有一个从 Itemsourceprovider 填充的 Telerik RadMulticolumnCombobox,我想要的是将此控件中的特定项目的 isEnable
设置为 false。
问题是我找不到任何发布此任务的属性。
<telerik:RadMultiColumnComboBox DisplayMemberPath="LastName"
NullText="Select employee to handle the order..."
Width="300"
DropDownWidth="530"
DropDownHeight="255">
<telerik:RadMultiColumnComboBox.ItemsSourceProvider>
<telerik:GridViewItemsSourceProvider AutoGenerateColumns="False" ItemsSource="{Binding Employees}" >
<telerik:GridViewItemsSourceProvider.Columns>
<telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}" />
<telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding City}" />
<telerik:GridViewDataColumn Header="Hire Date" DataMemberBinding="{Binding HireDate}" />
<telerik:GridViewDataColumn Header="Orders Count" DataMemberBinding="{Binding Orders.Count}" />
</telerik:GridViewItemsSourceProvider.Columns>
</telerik:GridViewItemsSourceProvider>
</telerik:RadMultiColumnComboBox.ItemsSourceProvider>
</telerik:RadMultiColumnComboBox>
我能做什么?
我的问题终于解决了!!
我不敢相信解决方案如此简单。
我创建了一个 rowStyle
并且我在我的 class
中创建了一个 propertyChanged
<telerik:GridViewItemsSourceProvider.RowStyle>
<Style TargetType="telerik:GridViewRow">
<Setter Property="IsEnabled" Value="{Binding IsSelected}">
</Setter>
</Style>
</telerik:GridViewItemsSourceProvider.RowStyle>
这是我的 class :
public class MyModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool isSelected;
public bool IsSelected
{
get { return isSelected; }
set
{
if (isSelected != value)
{
isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
并且我在我的 main 中设置了这个 属性 的值:
var models = new List<MyModel>();
// ....
foreach ( var m in models)
m.IsSelected = true;
var item = mycombob.selectedItem as MyModel;
item.IsSelected = false; // disable the selected item for example
我有一个从 Itemsourceprovider 填充的 Telerik RadMulticolumnCombobox,我想要的是将此控件中的特定项目的 isEnable
设置为 false。
问题是我找不到任何发布此任务的属性。
<telerik:RadMultiColumnComboBox DisplayMemberPath="LastName"
NullText="Select employee to handle the order..."
Width="300"
DropDownWidth="530"
DropDownHeight="255">
<telerik:RadMultiColumnComboBox.ItemsSourceProvider>
<telerik:GridViewItemsSourceProvider AutoGenerateColumns="False" ItemsSource="{Binding Employees}" >
<telerik:GridViewItemsSourceProvider.Columns>
<telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}" />
<telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding City}" />
<telerik:GridViewDataColumn Header="Hire Date" DataMemberBinding="{Binding HireDate}" />
<telerik:GridViewDataColumn Header="Orders Count" DataMemberBinding="{Binding Orders.Count}" />
</telerik:GridViewItemsSourceProvider.Columns>
</telerik:GridViewItemsSourceProvider>
</telerik:RadMultiColumnComboBox.ItemsSourceProvider>
</telerik:RadMultiColumnComboBox>
我能做什么?
我的问题终于解决了!! 我不敢相信解决方案如此简单。
我创建了一个 rowStyle
并且我在我的 class
propertyChanged
<telerik:GridViewItemsSourceProvider.RowStyle>
<Style TargetType="telerik:GridViewRow">
<Setter Property="IsEnabled" Value="{Binding IsSelected}">
</Setter>
</Style>
</telerik:GridViewItemsSourceProvider.RowStyle>
这是我的 class :
public class MyModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool isSelected;
public bool IsSelected
{
get { return isSelected; }
set
{
if (isSelected != value)
{
isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
并且我在我的 main 中设置了这个 属性 的值:
var models = new List<MyModel>();
// ....
foreach ( var m in models)
m.IsSelected = true;
var item = mycombob.selectedItem as MyModel;
item.IsSelected = false; // disable the selected item for example