Wpf ProgressBar.Value会奇怪地影响其他元素';s位置

Wpf ProgressBar.Value会奇怪地影响其他元素';s位置,wpf,vb.net,xaml,binding,Wpf,Vb.net,Xaml,Binding,除非我遗漏了一些基本的东西,否则这似乎是一个bug。它很容易复制。只需创建一个新的WPF应用程序项目,并将以下内容粘贴到main窗口的XAML中: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Main

除非我遗漏了一些基本的东西,否则这似乎是一个bug。它很容易复制。只需创建一个新的WPF应用程序项目,并将以下内容粘贴到
main窗口的XAML中:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="100" Width="525"
        xmlns:local="clr-namespace:WpfApplication1">
  <Grid>
    <ListBox>
      <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
          <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
          <Setter Property="IsTabStop" Value="False" />
        </Style>
      </ListBox.ItemContainerStyle>
      <ListBox.ItemTemplate>
        <DataTemplate DataType="{x:Type local:AudioFile}">
          <Grid HorizontalAlignment="Stretch">
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="3" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="32" />
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Width="24" Height="24" VerticalAlignment="Center" HorizontalAlignment="Left">
              <Image.Source>
                <BitmapImage UriSource="{Binding Icon}" />
              </Image.Source>
            </Image>
            <TextBlock Grid.Column="1" Text="{Binding FullPath}" VerticalAlignment="Center" />
            <ProgressBar Grid.Column="1" Opacity=".3" Foreground="LightGreen" Value="{Binding UploadProgress}" />
            <TextBlock Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="8">
              <Run Text="{Binding UploadRate, StringFormat={}{0:00}}" />
              <Run> kbps</Run>
            </TextBlock>
            <Image Grid.Column="2" Width="16" Height="16" VerticalAlignment="Center" />
            <ProgressBar Grid.Row="1" Grid.ColumnSpan="3" Value="{Binding PercentCompleted, Mode=OneWay}" />
          </Grid>
        </DataTemplate>
      </ListBox.ItemTemplate>
      <ListBox.Items>
        <local:AudioFile FullPath="C:\audio1.mp3" Status="Uploading" UploadProgress="0" PercentCompleted="40"  ErrorUploading="" />
      </ListBox.Items>
    </ListBox>
  </Grid>
</Window>

现在转到XAML并将
PercentCompleted
的值从
“40”
更改为
“80”
。注意
FullPath
TextBlock
向右移时的位置。为什么?我们对
完成百分比
的唯一绑定是
ProgressBar

,4年后再次绑定。再次面对同样的问题。这与绑定无关。硬编码值也会产生同样的效果。4年后再次出现。再次面对同样的问题。这与绑定无关。硬编码值也会产生相同的效果。
Public Class AudioFile
  Public Property FullPath() As String
  Public Property UploadProgress() As Integer
  Public Property UploadRate() As Single = 120
  Public Property Status() As String
  Public Property ErrorUploading() As String
  Public ReadOnly Property Icon() As String
    Get
      If String.IsNullOrEmpty(FullPath.Trim()) Then
        Return ""
      Else
        Dim RetVal As String = "Resources/speaker.png"

        Select Case System.IO.Path.GetExtension(FullPath).ToLower().Trim("."c)
          Case "mp3"
            RetVal = "Resources/mp3.png"
          Case "wav"
            RetVal = "Resources/wav.png"
        End Select

        Return RetVal
      End If
    End Get
  End Property
  Public Property PercentCompleted() As Integer
End Class