我是javascript的新手,是否可以在WPF中创建类似“Grid”的类容器? 没有jQuery等它是可取的。我需要在下面的XAML代码中创建像Grid这样的容器。
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="grid1">
<Grid.RowDefinitions>
<RowDefinition Height="30*"></RowDefinition>
<RowDefinition Height="30*"></RowDefinition>
<RowDefinition Height="30*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*">
</ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid x:Name="Grid2" Grid.Row="0" Grid.Column="0"></Grid>
</Grid>
答案 0 :(得分:0)
您可以使用:
HTML标记:
<table id="grid1">
<tr class="row30">
<td class="column100">
<table id="Grid2"></table>
</td>
<td></td>
</tr>
<tr class="row30">
<td class="column100"></td>
<td></td>
</tr>
<tr class="row30">
<td class="column100"></td>
<td></td>
</tr>
</table>
<强> CSS:强>
.row30{ height: 30px; }
.column100 { width: 100px; }
答案 1 :(得分:0)
在HTML中,只有Table元素提供类似的行为。它需要用css扩展,但是你可以创建一个类似网格的体验。如果你想要更多的功能,如排序,搜索和分页,我可以推荐jQuery DataTables。它是免费的,易于使用和快速。
这里有一些简单的JavaScript来创建一个表
var container = document.getElementById("container");
var newInner = "<table>";
newInner += "<thead>";
newInner += "<tr>";
newInner += "<th>Column1</th>";
newInner += "<th>Column2</th>";
newInner += "</tr>";
newInner += "</thead>";
newInner += "<tbody>";
for (var i=0;i< 100;i++)
{
newInner += "<tr>";
newInner += "<td>Content" + i + "_1</td>";
newInner += "<td>Content" + i + "_2</td>";
newInner += "</tr>";
}
newInner += "</tbody>";
newInner += "</table>";
container.innerHTML = newInner;
I've also created a Fiddle where you can check out jQuery Datatables