I have a screen that I use to show data from a data table. The XAML bindings are working and it displays fine. However, next to one data field, I have a button that I want to use for other things. My problem is that I don't want the button to show if the data field is null or empty. Below is snippets of the XAML and data object code that I am using.
XAML for the button:
I am starting out with the button hidden.
Here is the XAML that covers the style "DetailButton":
Here is the data object code that sets PplOlderFlag:
_bOlderFlag = (_sPplOlderInfo.Length > 0);
public bool PplOlderFlag
{
get
{
return _bOlderFlag;
}
}
As I s开发者_Go百科aid, the binding (PplOlderInfo) is working and show up fine. But the button is still there when the PplOlderInfo is null or empty.
I can set the Visibility of button in the code behind easy enough but it just seems like it would be really slick if I could make it work in the XAML.
Any ideas as to what I am leaving out or what I am doing wrong?
Shouldn't the type of PplOlderFlag be of type System.Windows.Visibility?
In my test app, if I make an equivalent property of type System.Windows.Visibility, I can make the button visible or invisible as required.
Edit:
From your code example, I would implement as:
public System.Windows.Visibility PplOlderFlag
{
get
{
return _bOlderFlag ? System.Windows.Visibility.Visible :
System.Windows.Visibility.Hidden;
}
}
精彩评论