簡體   English   中英

設置Text並添加Interaction.Triggers時出現奇怪的XAML Parse行為。 WPF

[英]Strange XAML Parse behaviour when set Text and add Interaction.Triggers. WPF

我設置了Textbox控件的Text屬性,並且還為它添加了Interaction.Trigger。 拋出異常當我嘗試使用XamlReader.Parse()解析此XAML時:

我擁有的xaml是:

<Grid xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"        
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        Name="TopPanel" >
    <Grid.ColumnDefinitions>
        <ColumnDefinition />        
    </Grid.ColumnDefinitions>  
    <Grid.RowDefinitions>       
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>  
    <TextBox Name="TextBox_8241" FocusManager.IsFocusScope="True" Grid.Column="1" Grid.Row="1" xml:space="preserve" 
            Text="{Binding ppp, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">    
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter">        
                    <cmd:EventToCommand PassEventArgsToCommand="True" Command="{Binding TextBox_8241_MouseEnterCommand}" />      
                </i:EventTrigger>    
            </i:Interaction.Triggers>  
    </TextBox>
</Grid>

異常消息是:{“''Text'屬性已在'TextBox'上設置。' 行號“1”和行位置“X”。“}

行位置指向TextBox </TextBox>的結束標記

如果我沒有設置任何Interaction.Triggers它解析好,但至少有一個Interaction.Triggers設置,它會拋出異常......

請問有人對此有所了解嗎?

問題出在TextBox聲明中的xml:space="preserve"行。 如果你放棄它,它將按預期解析。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM