Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.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
.net WPF Progressbar赢得';不要左对齐_.net_Wpf_Xaml_Alignment_Progress Bar - Fatal编程技术网

.net WPF Progressbar赢得';不要左对齐

.net WPF Progressbar赢得';不要左对齐,.net,wpf,xaml,alignment,progress-bar,.net,Wpf,Xaml,Alignment,Progress Bar,我使用以下XAML代码在窗口中显示一组控件: <Grid Height="80"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowD

我使用以下XAML代码在窗口中显示一组控件:

<Grid Height="80">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Width="80" />

    <TextBlock Grid.Column="1" Grid.Row="0" Margin="5" FontWeight="Bold" Text="{Binding Titel}"
               Foreground="#B0B0B0" VerticalAlignment="Top" />
    <TextBlock Grid.Column="1" Grid.Row="1" Margin="5,0" Text="{Binding Description}" Foreground="#c9c9c9"
               VerticalAlignment="Top" />
    <ProgressBar Grid.Column="1" Grid.Row="2" Value="50" Margin="5" Height="15" MaxWidth="200" />

</Grid>

有人知道如何使这项工作吗?

您可以尝试绑定到其他元素的宽度:

<TextBlock x:Name="title" Grid.Column="1" Grid.Row="0" Margin="5" FontWeight="Bold" Text="{Binding Titel}" Foreground="#B0B0B0" VerticalAlignment="Top" />

<ProgressBar Grid.Column="1" Grid.Row="2" Value="50" Margin="5" Height="15" Width="{Binding Path=ActualWidth, ElementName=title}" MaxWidth="200" HorizontalAlignment="Left"/>

您还可以将
进度条
包装在
网格
中,其中两列定义如下:

<Grid Grid.Column="1" Grid.Row="2">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" MaxWidth="200"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <ProgressBar Grid.Column="0" Value="50" Margin="5" Height="15"/>
</Grid>

<TextBlock x:Name="title" Grid.Column="1" Grid.Row="0" Margin="5" FontWeight="Bold" Text="{Binding Titel}" Foreground="#B0B0B0" VerticalAlignment="Top" />

<ProgressBar Grid.Column="1" Grid.Row="2" Value="50" Margin="5" Height="15" Width="{Binding Path=ActualWidth, ElementName=title}" MaxWidth="200" HorizontalAlignment="Left"/>
<Grid Grid.Column="1" Grid.Row="2">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" MaxWidth="200"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <ProgressBar Grid.Column="0" Value="50" Margin="5" Height="15"/>
</Grid>