.net WPF Progressbar赢得';不要左对齐
我使用以下XAML代码在窗口中显示一组控件:.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
<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>