我有一个数据库表,其中有一个名为Status的列,"Status“列中的值将为1或0或Null。我试图实现的是,如果值为1,它应该在上显示,如果值为0,则应该显示Off,如果值为null,则应该显示null。下面是一些我已经尝试过的片段,我无法找到如何根据表列值来显示结果。我正在附上数据库的样本输出。在这种情况下,请给我提供一些可以锻炼的想法。
#Accessing table value
public IQueryable<MSDS_VII> GetMSDS()
{
return (
from r in this._context.MSDS_VII
orderby r.NO
select r);
}
#Creating ria service
public void GetMSDS(Action<CustomLoadOperation<MSDS_VII>> loadCompleted, object
userState = null, int pageSize = 20)
{
new CustomDataAdapter<MSDS_VII>(this.client, this.client.GetMSDSQuery(), this.client.MSDS_VIIs, pageSize, loadCompleted, userState);
}
#View Model
public class MSDSStatusViewModel : BaseViewModel
{
[ImportingConstructor]
public MSDSStatusViewModel(IWindowManager windowManager, IEventAggregator eventAggregator, DomainServiceClient service)
: base()
{
this.windowManager = windowManager;
this.service = service;
this.eventAggregator = eventAggregator;
this.DisplayName = "MSDS VII Status";
}
public DomainCollectionView<MSDS_VII> msdsList;
public DomainCollectionView<MSDS_VII> MSDSList
{
get
{
return this.msdsList;
}
set
{
this.msdsList = value;
this.NotifyOfPropertyChange(() => MSDSList);
}
}
public override void GetData()
{
this.service.GetMSDS(this.OnGeneralItemsLoadCompleted<MSDS_VII>);
}
public override void OnGeneralItemsLoadCompleted<TEntity>(CustomLoadOperation<TEntity> result)
{
base.OnGeneralItemsLoadCompleted(result);
if (result.Result.IsComplete)
{
if (typeof(TEntity).Equals(typeof(MSDS_VII)))
{
MSDSList = result.CollectionView as DomainCollectionView<MSDS_VII>;
}
}
}
#View xaml code
<c1:C1FlexGrid Grid.Row="1" ItemsSource="{Binding MSDSList}" AutoGenerateColumns="False" HeadersVisibility="Column" GroupRowPosition="BelowData" MaxColumnWidth="500" c1:LicenseMode.Evaluation="True">
<c1:C1FlexGrid.Columns>
<c1:Column Binding="{Binding NO}" Header="NO."Width="70" />
<c1:Column Binding="{Binding ITEM}" Header="Item" Width="400" />
<c1:Column Binding="{Binding STATUS}" Header="Status" Width="130" />
</c1:C1FlexGrid.Columns>
</c1:C1FlexGrid>
发布于 2020-02-11 13:27:08
您需要创建一个自定义转换器来将值转换为适合控件的值,反之亦然。网上有很多例子。我在快速搜索之后找到了这个应该对你有帮助的。IValueConvertor
https://stackoverflow.com/questions/60145290
复制相似问题