2017-09-20 15 views
0

検証エラーが発生したときに "Template10.Validation"スタイルを変更します。 私のターゲット・スタイルです。Template10.Validation/UWP/C#新しいデザインを作るには? 、エラー:コレクションプロパティ__implicit_properyがnullです

enter image description here

と私は..試みたが、ここで奇妙なエラーがあります...

<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>                           

エラーメッセージ "コレクションのプロパティ__implicit_properyがnull" である

enter image description here

1 ) "Microsoft.Xaml.Behaviors.Uwp.Managed"のver 1.1とver 2.0の両方を試しました

なぜエラーが発生したのかわかりません。 アドバイスをお願いしますか、私のデザインのスタイルを作っていただけますか?

答えて

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> 

enter image description here

+0

良いです! : ) ありがとうございました ! –

関連する問題