! 我需要对齐listview中存在的文本块(PhoneTxt,CreateddateTxt)。
var opposite = 1
var adjacent = 1
var hypotenuse = 1
var sct = "SohCahToa"
while (!(sct == "Sine" || sct == "Cosine" || sct == "Tangent")) {
sct = prompt("Sine (unknown adjacent) / Cosine (unkown opposite side) / Tangent (unknown hypotenuse)")
(!(sct == "Sine" || sct == "Cosine" || sct == "Tangent")) {
alert("Spelling error, please try again")
}
}
if (sct == "Sine" || sct == "Cosine")
hypotenuse = prompt("What is the hypotenuse")
if (sct == "Sine" || sct == "Tangent")
opposite = prompt("What is the opposite side")
if (sct == "Tangent" || sct == "Cosine")
adjacent = prompt("What is the adjacent side")
@Schuere他们之间存在很大的差距......在应用你的代码之后
我需要显示。(即在输出中)将它们一起打印在同一行中并留出一些空间..
@ fillobotto我需要显示这些文本块以及它们之间的一个或两个空格
答案 0 :(得分:1)
试试这个
<ListBox Background="Transparent" HorizontalAlignment="Left" Height="auto" BorderThickness="1" MaxHeight="580" Grid.Row="1" Margin="6" VerticalAlignment="Top" Width="352" Name="DaysLeftListView" SelectionChanged="DaysLeftListView_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="350" >
<Border Margin="5" BorderBrush="White" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" x:Name="NameTxt" TextWrapping="Wrap" Text="{Binding Events}" FontSize="28" Foreground="White"/>
<TextBlock Text=">" FontSize="28" Margin="5,0,0,0" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Name="PhoneTxt" TextWrapping="Wrap" Foreground="White" FontSize="18" Text="{Binding diff}" />
<TextBlock Margin="5,0,0,0" Name="CreateddateTxt" Foreground="White" FontSize="18" TextWrapping="Wrap" Text="{Binding result}" />
</StackPanel>
</Grid>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Orientation="Horizontal"
失踪
答案 1 :(得分:0)
创建一些额外的columndefinitions:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinitions Width="Auto"/>
<ColumnDefinitions Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Margin="5,0,0,0" Grid.Row="0" Grid.Column="0" ColumnSpan x:Name="NameTxt" TextWrapping="Wrap" Text="{Binding Events}" FontSize="28" Foreground="White"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text=">" FontSize="28" HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Margin="5,0,0,0" Grid.Row="1" Grid.Column="0" Name="PhoneTxt" TextWrapping="Wrap" Foreground="White" FontSize="18" Text="{Binding diff}" />
<TextBlock Margin="0,0,35,0" Grid.Row="1" Grid.Column="1" Name="CreateddateTxt" Foreground="White" FontSize="18" TextWrapping="Wrap" Text="{Binding result}" />
</Grid>
这应该改变结果,CreateddateTxt应该在PhoneTxt旁边
答案 2 :(得分:0)
我不完全理解您想要对齐哪个TextBlock
,但是您应该使用StackPanel
控件并将其Orientation
属性设置为Horizontal。
<ListBox Background="Transparent" HorizontalAlignment="Left" Height="auto" BorderThickness="1" MaxHeight="580" Grid.Row="1" Margin="6" VerticalAlignment="Top" Width="352" Name="DaysLeftListView" SelectionChanged="DaysLeftListView_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="350" >
<Border Margin="5" BorderBrush="White" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Margin="5,0,0,0" Grid.Row="0" x:Name="NameTxt" TextWrapping="Wrap" Text="{Binding Events}" FontSize="28" Foreground="White"/>
<TextBlock Grid.Row="0" Text=">" FontSize="28" HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="White"/>
<StackPanel Grid.Row="1">
<TextBlock Margin="5,0,0,0" Name="PhoneTxt" TextWrapping="Wrap" Foreground="White" FontSize="18" Text="{Binding diff}" />
<TextBlock Margin="5,0,0,0" Name="CreateddateTxt" Foreground="White" FontSize="18" TextWrapping="Wrap" Text="{Binding result}" />
</StackPanel>
</Grid>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>