根据值隐藏单元格内容 [英] Hide cell content based on value

查看:87
本文介绍了根据值隐藏单元格内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

partial void CustomerSearchScreen_InitializeDataWorkspace(List<IDataService> saveChangesTo)
{
	Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() =>
	{
		var proxy = this.FindControl("gridCustomers");
		proxy.ControlAvailable += proxy_ControlAvailable;
	});
}

private void proxy_ControlAvailable(object sender, ControlAvailableEventArgs e)
{
	var ctrl = (DataGrid)e.Control;
	ctrl.LoadingRow += ctrl_LoadingRow;
}

void ctrl_LoadingRow(object sender, DataGridRowEventArgs e)
{
	DataGrid grid = (DataGrid)sender;
	DataGridRow row = new DataGridRow();
	row = e.Row;

	var cellHasNoAdress = this.FindControlInCollection("imgHasNoAdress", row.DataContext as Customer);
	cellHasNoAdress.IsVisible = true.Equals(((Customer)row.DataContext).IsValidCustomer);

	var cellName = this.FindControlInCollection("Name", row.DataContext as Customer);
	cellName.IsVisible = true.Equals(((Customer)row.DataContext).IsValidCustomer);

	Debug.WriteLine(((Customer)row.DataContext).Name + ":" + ((Customer)row.DataContext).IsValidCustomer);
}

1)在上面的代码中,想要隐藏标题为"No Adress"的列. (名为imgHasNoAdress).但这仅适用于名称"列.

1) With the code above a wanted to hide the column with the header "No Adress" (named imgHasNoAdress). But it only works for the column "Name".

名称"列绑定到名称",而无地址"列绑定到名称".已使用添加文本..."添加.

The Name column is bound to "Name", the column "No Adress" has been added using "Add Text ...".

如何隐藏!"基于是否是有效客户"的值?

How can I hide the "!" based on the value of "Is Valid Customer"?

2)为什么代码执行两次?这是我的debug-output窗口的输出(请参阅最后一行代码):

2) Why Is the code performed twice? This is the output (see last line of code) of my debug-output window:

客户A:

客户A:

客户B:真实

客户B:真实

客户C:

客户C:

推荐答案

我感觉到您要隐藏单元格值,而不是<强> 列.顺便说一句,您可以使列 visible 可见,或者 不可见,对于某些行,您无法将其设置为可见. 对于其他人不可见.

I have a feeling that you're trying to hide cell values, not columns. Just as an aside, you can either make a column visible, or not visible, you can't make it visible for some rows & not visible for others.

如果我怀疑您实际上是在尝试操作属性值 在行中,您可以通过两种方式进行操作.

If, as I suspect, you're actually trying to manipulate property values in rows, there are two ways you could do that.

  1. 计算的属性-在非常简单的情况下,计算的属性可能可以正常运行,但要提防性能下降.
  2. 自定义 RIA服务-这是我处理任何合理的复杂情况的方式,在这种情况下,计算属性的性能将不够好.
  1. Computed Properties - for very simple scenarios, computed properties might work OK, but beware the performance hit.
  2. Custom RIA Service - this is the way I handle any reasonably complex scenarios, where the performance of computed properties would not be good enough.


这篇关于根据值隐藏单元格内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆