Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin-XAML条件样式_Xaml_Xamarin_Styles_Conditional_Datatrigger - Fatal编程技术网

Xamarin-XAML条件样式

Xamarin-XAML条件样式,xaml,xamarin,styles,conditional,datatrigger,Xaml,Xamarin,Styles,Conditional,Datatrigger,我在列表视图中有一个StackLayout,我想根据对象是否具有PerformedDate值(默认为null)来隐藏它(IsVisible=“false”) 现在,我试图在堆栈布局上使用数据触发器,使用标签的文本作为指示对象是否具有PerformedDate: <Label x:Name="PerformedDateLabel" Text="{Binding PerformedDate}" IsVisible="True"/> <StackLayout Padding="0,

我在
列表视图中有一个
StackLayout
,我想根据对象是否具有
PerformedDate
值(默认为
null
)来隐藏它(
IsVisible=“false”

现在,我试图在
堆栈布局上使用
数据触发器
,使用
标签
的文本作为指示对象是否具有
PerformedDate

<Label x:Name="PerformedDateLabel" Text="{Binding PerformedDate}" IsVisible="True"/>
<StackLayout Padding="0, 25, 0, 0" Spacing="0">
    <Label Text="{Binding Date, StringFormat='{0:dd}'}" FontSize="Small" HorizontalOptions="Center"/>
    <Label Text="{Binding Date, StringFormat='{0:MMM}'}" HorizontalOptions="Center"/>
    <StackLayout.Triggers>
        <DataTrigger TargetType="StackLayout" Binding="{Binding Source={x:Reference PerformedDateLabel}, Path=Text}" Value="">
            <Setter Property="IsVisible" Value="False"/>
        </DataTrigger>
    </StackLayout.Triggers>
</StackLayout>

PerformedDate
存在时,它不会隐藏
StackLayout
。 有什么想法吗


我还尝试了
Path=Text.Length
Value=“0”
方法。

您可以使用附加属性
hasperpermeddate

C#

公共日期时间?执行日期
{
获取{return\u performedDate;}
设置
{
_performedDate=值;
OnPropertyChanged();
已更改的不动产(名称(HasPerformedDate));
}
}
public bool HasPerformedDate=>PerformedDate.HasValue;
Xaml


ahh是的,我也考虑过这种方式,不知道我的项目需求是否允许我通过添加额外的属性来更改对象,这些属性专门用于查看目的。如果我最终这样做,我会接受的。感谢您的输入:]