Template10.Validation/UWP/C# How to make new design ? , error : Collection property __implicit_propery is null
Template10.Validation/UWP/C# How to make new design ? , error : Collection property __implicit_propery is null
我想在发生验证错误时修改“Template10.Validation”样式。
这是我的目标样式。
我试过了..但是有奇怪的错误...
<validate:ControlWrapper Property="{Binding SettingEmailModel}" PropertyName="EmailReceivers">
<validate:ControlWrapper.Template>
<ControlTemplate TargetType="validate:ControlWrapper">
<StackPanel DataContext="{TemplateBinding Property}">
<TextBlock Text="IsValid" />
<TextBlock Text="{Binding IsValid}" />
<TextBlock Text="Errors" />
<TextBlock Text="{Binding Errors.Count}" />
<ContentPresenter Content="{TemplateBinding Content}" />
<TextBlock x:Name="ValidationNotifyTextBlock" Text="{Binding Errors[0]}">
<Interactivity:Interaction.Behaviors>
<Core:DataTriggerBehavior Binding="{Binding IsValid}" Value="True">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=ValidationNotifyTextBlock}"
PropertyName="Foreground" Value="Red"/>
</Core:DataTriggerBehavior>
<Core:DataTriggerBehavior Binding="{Binding IsValid}" Value="False">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=ValidationNotifyTextBlock}"
PropertyName="Foreground" Value="Black"/>
</Core:DataTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBlock>
</StackPanel>
</ControlTemplate>
</validate:ControlWrapper.Template>
<Grid>
<TextBox Text="{Binding SettingEmailModel.EmailReceivers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MinHeight="400" Style="{StaticResource SettingStyle_MultilineTextBox}"/>
</Grid>
</validate:ControlWrapper>
这是错误信息"Collection property __implicit_propery is null"
1) 我尝试了“Microsoft.Xaml.Behaviors.Uwp.Managed”
的 ver 1.1 和 ver 2.0
我不知道为什么会发生错误..
请给我建议,或者,你能为我的设计制作一个样式吗?
根据您的要求,您可以为已验证的 TextBox
创建 ErrorTextBoxStyle
。并在下面的 ControlWrapper
ControlTemplate.
中使用它
<validate:ControlWrapper PropertyName="FirstName">
<validate:ControlWrapper.Template>
<ControlTemplate TargetType="validate:ControlWrapper">
<Grid>
<ContentPresenter Content="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
</validate:ControlWrapper.Template>
<TextBox
Width="{StaticResource FieldWidth}"
Header="First Name"
Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<Interactivity:Interaction.Behaviors>
<behaviors:ValidationBehavior PropertyName="FirstName">
<behaviors:ValidationBehavior.WhenValidActions>
<Core:ChangePropertyAction PropertyName="Style" Value="{x:Null}" />
</behaviors:ValidationBehavior.WhenValidActions>
<behaviors:ValidationBehavior.WhenInvalidActions>
<Core:ChangePropertyAction PropertyName="Style" Value="{StaticResource ErrorTextBoxStyle}" />
</behaviors:ValidationBehavior.WhenInvalidActions>
</behaviors:ValidationBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
</validate:ControlWrapper>
ErrorTextBoxStyle
<Style x:Key="ErrorTextBoxStyle" TargetType="TextBox">
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" Value="Red"/>
</Style>
我想在发生验证错误时修改“Template10.Validation”样式。 这是我的目标样式。
我试过了..但是有奇怪的错误...
<validate:ControlWrapper Property="{Binding SettingEmailModel}" PropertyName="EmailReceivers">
<validate:ControlWrapper.Template>
<ControlTemplate TargetType="validate:ControlWrapper">
<StackPanel DataContext="{TemplateBinding Property}">
<TextBlock Text="IsValid" />
<TextBlock Text="{Binding IsValid}" />
<TextBlock Text="Errors" />
<TextBlock Text="{Binding Errors.Count}" />
<ContentPresenter Content="{TemplateBinding Content}" />
<TextBlock x:Name="ValidationNotifyTextBlock" Text="{Binding Errors[0]}">
<Interactivity:Interaction.Behaviors>
<Core:DataTriggerBehavior Binding="{Binding IsValid}" Value="True">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=ValidationNotifyTextBlock}"
PropertyName="Foreground" Value="Red"/>
</Core:DataTriggerBehavior>
<Core:DataTriggerBehavior Binding="{Binding IsValid}" Value="False">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=ValidationNotifyTextBlock}"
PropertyName="Foreground" Value="Black"/>
</Core:DataTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBlock>
</StackPanel>
</ControlTemplate>
</validate:ControlWrapper.Template>
<Grid>
<TextBox Text="{Binding SettingEmailModel.EmailReceivers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MinHeight="400" Style="{StaticResource SettingStyle_MultilineTextBox}"/>
</Grid>
</validate:ControlWrapper>
这是错误信息"Collection property __implicit_propery is null"
1) 我尝试了“Microsoft.Xaml.Behaviors.Uwp.Managed”
的 ver 1.1 和 ver 2.0我不知道为什么会发生错误.. 请给我建议,或者,你能为我的设计制作一个样式吗?
根据您的要求,您可以为已验证的 TextBox
创建 ErrorTextBoxStyle
。并在下面的 ControlWrapper
ControlTemplate.
<validate:ControlWrapper PropertyName="FirstName">
<validate:ControlWrapper.Template>
<ControlTemplate TargetType="validate:ControlWrapper">
<Grid>
<ContentPresenter Content="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
</validate:ControlWrapper.Template>
<TextBox
Width="{StaticResource FieldWidth}"
Header="First Name"
Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<Interactivity:Interaction.Behaviors>
<behaviors:ValidationBehavior PropertyName="FirstName">
<behaviors:ValidationBehavior.WhenValidActions>
<Core:ChangePropertyAction PropertyName="Style" Value="{x:Null}" />
</behaviors:ValidationBehavior.WhenValidActions>
<behaviors:ValidationBehavior.WhenInvalidActions>
<Core:ChangePropertyAction PropertyName="Style" Value="{StaticResource ErrorTextBoxStyle}" />
</behaviors:ValidationBehavior.WhenInvalidActions>
</behaviors:ValidationBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
</validate:ControlWrapper>
ErrorTextBoxStyle
<Style x:Key="ErrorTextBoxStyle" TargetType="TextBox">
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" Value="Red"/>
</Style>