我有list1 <- data.frame(Group.1 = c(1, 2), x = c(4000, 3890) )
list1$Group.1 <- str_replace(list1$Group.1, "1", "male")
list1$Group.1 <- str_replace(list1$Group.1, "2", "female")
list1
Group.1 x
1 male 4000
2 female 3890
页面:
Xaml
将 <StackPanel Orientation="Horizontal">
<Grid x:Name="inkGrid0" Margin="0,0,0,0" HorizontalAlignment="Left" >
<Canvas x:Name="inkCanvas0" Width="570">
<Canvas.Background>
<ImageBrush x:Name="DImage0" ImageSource="{Binding}"/>
</Canvas.Background>
</Canvas>
</Grid>
<Grid x:Name="inkGrid1" Margin="0,0,0,0" HorizontalAlignment="Right" >
<Canvas x:Name="inkCanvas1" Width="570">
<Canvas.Background>
<ImageBrush x:Name="DImage1" ImageSource="{Binding}"/>
</Canvas.Background>
</Canvas>
</Grid>
</StackPanel>
添加到我的代码后,inkGrid0.Visibility = Visibility.Collapsed
会占据inkGrid1
的左侧位置,该位置现已折叠。
如果inkGrid0
崩溃,如何在其位置inkGrid1
?
答案 0 :(得分:0)
您可以使用Visibility.Hidden
。但是,我提出了一个更优雅的解决方案,即使用Grid
和ColumnDefinitions
。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Your Controls Here -->
<Grid x:Name="inkGrid0" ... />
<Grid x:Name="inkGrid1" Grid.Column="1" ... />
</Grid>
答案 1 :(得分:0)
如果您不想处理调整大小等问题,只需将其不透明度设置为0.但是,您必须考虑点击或点击等交互。
设置不透明度而不是可见性在性能方面非常有用,而且很容易。
答案 2 :(得分:-1)
<StackPanel Orientation="Horizontal">
<Grid x:Name="inkGrid0" Margin="0,0,0,0" HorizontalAlignment="Left" Background="Black" Visibility="Hidden">
<Canvas x:Name="inkCanvas0" Width="570">
<Canvas.Background>
<ImageBrush x:Name="DImage0" />
</Canvas.Background>
</Canvas>
</Grid>
<Grid x:Name="inkGrid1" Margin="0,0,0,0" HorizontalAlignment="Right" Background="Blue" >
<Canvas x:Name="inkCanvas1" Width="570">
<Canvas.Background>
<ImageBrush x:Name="DImage1" />
</Canvas.Background>
</Canvas>
</Grid>
</StackPanel>
您可以使用Visibility.Hidden或使用固定列宽
<StackPanel Orientation="Horizontal">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="570" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid x:Name="inkGrid01" Margin="0,0,0,0" HorizontalAlignment="Left" Background="Black" Visibility="Collapsed">
<Canvas x:Name="inkCanvas01" Width="570">
<Canvas.Background>
<ImageBrush x:Name="DImage111" />
</Canvas.Background>
</Canvas>
</Grid>
<Grid x:Name="inkGrid11" Margin="0,0,0,0" HorizontalAlignment="Right" Background="Blue" Grid.Column="1">
<Canvas x:Name="inkCanvas11" Width="570">
<Canvas.Background>
<ImageBrush x:Name="DImage11" />
</Canvas.Background>
</Canvas>
</Grid>
</Grid>
</StackPanel>