如何设置GridView中的项目填充整个高度? 我想GridView总是有4行。目前我设置图像的高度为120.
我的代码:
org.osgi.framework.BundleException: The bundle file:/opt/agent/deploy/System_Install-1.0.jar does not have a META-INF/MANIFEST.MF! Make sure, META-INF and MANIFEST.MF are the first 2 entries in your JAR!
答案 0 :(得分:0)
创建一个转换器类,用输入参数除以Window高度:
class DivisionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string culture)
{
double windowHeight = Window.Current.Bounds.Height;
double divideBy = Double.Parse(parameter as string);
return windowHeight / divideBy;
}
public object ConvertBack(object value, Type targetType, object parameter, string culture)
{
throw new NotSupportedException();
}
}
在XAML中使转换器可用:
<Page .... >
<Page.Resources>
<local:DivisionConverter x:Key="DivisionConverter"/>
</Page.Resources>
然后使用带数据绑定的转换器:
<Image
x:Name="ima"
Height="{Binding Converter={StaticResource DivisionConverter}, ConverterParameter=5}"
Stretch="UniformToFill">
请注意,我除以5,因为项目周围总是有边距和填充,这会阻止您插入5行:Image.Height * 5 + margins > Grid.Height
。