{"id":66,"date":"2008-07-15T01:12:51","date_gmt":"2008-07-15T01:12:51","guid":{"rendered":"http:\/\/tw.newtonstudio.com\/?p=66"},"modified":"2008-07-15T01:12:51","modified_gmt":"2008-07-15T01:12:51","slug":"silverlight2-layout-control%e4%bb%8b%e7%b4%b9","status":"publish","type":"post","link":"http:\/\/tw.newtonstudio.com\/?p=66","title":{"rendered":"[SilverLight2] Layout Control\u4ecb\u7d39"},"content":{"rendered":"<p>\u5728SilverLight\u4e2d\u7528\u4f86\u898f\u5283\u6574\u500b\u7248\u9762Layout\u7684Control\u4e3b\u8981\u6709\u4e09\u7a2e:<\/p>\n<ul>\n<li>Grid: \u5c31\u50cfTable\u4e00\u6a23, \u5c07\u7269\u4ef6\u4ee5\u884c\u5217\u7684\u65b9\u5f0f\u5c0d\u9f4a<\/li>\n<li>StackPanel: \u8b93\u7269\u4ef6\u4e4b\u9593\u76f8\u5c0d\u5c0d\u9f4a, \u5982\u76f8\u9130\u5c0d\u9f4a\u6216\u5411\u4e0a\u5c0d\u9f4a<\/li>\n<li>Canvas: \u7528\u7d55\u5c0d\u5c0d\u9f4a(absolute positioning) \u7684\u65b9\u5f0f\u653e\u7f6e\u7269\u4ef6(\u8207SilverLight 1.0\u76f8\u7b26)<\/li>\n<\/ul>\n<p><strong>Grid<\/strong><\/p>\n<p>Grid \u5728\u4f7f\u7528VS2008\u958b\u555f\u65b0\u6a94\u6848\u7684\u6642\u5019\u5c31\u5df2\u7d93\u5b58\u5728XAML\u88e1\u9762\u4e86, \u683c\u5f0f\u6703\u9577\u9019\u500b\u6a23\u5b50:<\/p>\n<blockquote>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">&lt;<span style=\"color: #a31515;\">UserControl<\/span><span style=\"color: red;\"> x<\/span>:<span style=\"color: red;\">Class<\/span>=&#8221;EasyGrid.Page&#8221;<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">xmlns<span style=\"color: blue;\">=&#8221;http:\/\/schemas.microsoft<\/span><span style=\"color: blue;\">.com\/winfx\/2006\/xaml\/presentation&#8221;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">xmlns<span style=\"color: blue;\">:<\/span>x<span style=\"color: blue;\">=&#8221;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&#8221;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">Width<span style=\"color: blue;\">=&#8221;400&#8243;<\/span> Height<span style=\"color: blue;\">=&#8221;300&#8243;&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><strong>&lt;<span style=\"color: #a31515;\">Grid<\/span><span style=\"color: red;\"> x<\/span>:<span style=\"color: red;\">Name<\/span>=&#8221;LayoutRoot&#8221;<span style=\"color: red;\"> Background<\/span>=&#8221;White&#8221;&gt;<\/strong><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><strong>&lt;\/Grid&gt;<\/strong><\/p>\n<\/blockquote>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">\u4f60\u53ef\u4ee5\u5148\u898f\u5283\u6574\u500bSilverLight App\u7684\u6846\u7dda, \u4ee5\u4fbf\u4e4b\u5f8c\u7684\u5c0d\u9f4a\u4f5c\u696d, \u5b9a\u7fa9\u7684\u65b9\u5f0f\u5982\u4e0b:<\/p>\n<blockquote>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">&lt;<span style=\"color: #a31515;\">Grid<\/span><span style=\"color: red;\"> x<\/span>:<span style=\"color: red;\">Name<\/span>=&#8221;LayoutRoot&#8221;<span style=\"color: red;\"> Background<\/span>=&#8221;White&#8221;&gt;<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>Grid.RowDefinitions<span style=\"color: blue;\">&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>RowDefinition<span style=\"color: red;\"> Height<\/span><span style=\"color: blue;\">=&#8221;50&#8243; \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>RowDefinition<span style=\"color: red;\"> Height<\/span><span style=\"color: blue;\">=&#8221;30*&#8221;<\/span><span style=\"color: red;\"> MaxHeight<\/span><span style=\"color: blue;\">=&#8221;70&#8243;<\/span> <span style=\"color: blue;\"> \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>RowDefinition<span style=\"color: red;\"> Height<\/span><span style=\"color: blue;\">=&#8221;40*&#8221;<\/span><span style=\"color: red;\"> MaxHeight<\/span><span style=\"color: blue;\">=&#8221;70&#8243; \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>RowDefinition<span style=\"color: red;\"> Height<\/span><span style=\"color: blue;\">=&#8221;*&#8221;<\/span><span style=\"color: red;\"> MinHeight<\/span><span style=\"color: blue;\">=&#8221;30&#8243;<\/span><span style=\"color: red;\"> MaxHeight<\/span><span style=\"color: blue;\">=&#8221;50&#8243; \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>RowDefinition<span style=\"color: red;\"> Height<\/span><span style=\"color: blue;\">=&#8221;Auto&#8221;<\/span><span style=\"color: red;\"> MinHeight<\/span><span style=\"color: blue;\">=&#8221;5&#8243;<\/span><span style=\"color: red;\"> MaxHeight<\/span><span style=\"color: blue;\">=&#8221;30&#8243; \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;\/<\/span>Grid.RowDefinitions<span style=\"color: blue;\">&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;\/Grid&gt;<\/span><\/p>\n<\/blockquote>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><strong>Height<\/strong>: \u6bcf\u4e00\u5217\u7684\u9ad8\u5ea6<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><strong>MaxHeight<\/strong>: \u80fd\u5920\u62c9\u4f38\u7684\u6700\u5927\u9ad8\u5ea6 (* \u8868\u793a\u4ee5\u6bd4\u4f8b\u7684\u65b9\u5f0f\u5b9a\u7fa9\u9ad8\u5ea6, \u5169\u500d\u9ad8\u5c31\u662f 2*)<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><strong>MinHeight<\/strong>: \u80fd\u5920\u62c9\u4f38\u7684\u6700\u5c0f\u9ad8\u5ea6<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><strong>StackPanel<\/strong><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">Stack\u5c31\u662f\u5806\u758a\u7684\u610f\u601d, \u4f7f\u7528StackPanel\u4f60\u53ef\u4ee5\u5c07\u4f60\u7684\u7269\u4ef6\u4ee5\u5de6\u53f3\u5806\u758a\u6216\u8005\u4e0a\u4e0b\u5806\u758a\u7684\u65b9\u5f0f\u6392\u5217, \u5c31\u50cf\u66f8\u672c\u5728\u66f8\u67b6\u4e0a\u4e00\u6a23. \u5b83\u4e5f\u662f\u5728SilverLight2.0\u7d93\u5e38\u4f7f\u7528\u7684\u5c0d\u9f4a\u5de5\u5177. \u4e0b\u9762\u4ee5\u653e\u7f6eTextBlock, TextBox, CheckBox\u53caButton \u70ba\u4f8b:<\/p>\n<blockquote>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">&lt;<span style=\"color: #a31515;\">StackPanel<\/span><span style=\"color: red;\"> Background<\/span>=&#8221;Beige&#8221;<span style=\"color: red;\"> Orientation<\/span>=&#8221;Vertical&#8221;  &gt;<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>TextBlock<span style=\"color: red;\"> Text<\/span><span style=\"color: blue;\">=&#8221;Your name?&#8221;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">HorizontalAlignment<span style=\"color: blue;\">=&#8221;Left&#8221;<\/span> Margin<span style=\"color: blue;\">=&#8221;10,2,0,1&#8243;\/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;<\/span>TextBox<span style=\"color: red;\"> Width<\/span><span style=\"color: blue;\">=&#8221;150&#8243;<\/span><span style=\"color: red;\"> Height<\/span><span style=\"color: blue;\">=&#8221;30&#8243;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">HorizontalAlignment<span style=\"color: blue;\">=&#8221;Left&#8221;<\/span> Margin<span style=\"color: blue;\">=&#8221;10,2,0,1&#8243;\/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: #a31515;\"> <\/span>&lt;<span style=\"color: #a31515;\">Button<\/span><span style=\"color: red;\"> Content<\/span>=&#8221;Submit this information&#8221;<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">HorizontalAlignment<span style=\"color: blue;\">=&#8221;Left&#8221;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">Margin<span style=\"color: blue;\">=&#8221;10,2,0,1&#8243;<\/span> Height<span style=\"color: blue;\">=&#8221;30&#8243;<\/span> Width<span style=\"color: blue;\">=&#8221;150&#8243; \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: #a31515;\"> <\/span>&lt;<span style=\"color: #a31515;\">CheckBox<\/span><span style=\"color: red;\"> Content<\/span>=&#8221;With Zing!&#8221;<span style=\"color: red;\"> HorizontalAlignment<\/span>=&#8221;Left&#8221;<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: red;\"> Margin<\/span><span style=\"color: blue;\">=&#8221;10,2,0,1&#8243; \/&gt;<\/span><\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\"><span style=\"color: blue;\">&lt;\/<\/span>StackPanel<span style=\"color: blue;\">&gt;<\/span><\/p>\n<\/blockquote>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">\u5c6c\u6027:<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">Background: Stack\u80cc\u666f\u7684\u984f\u8272<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">Orientation: \u6392\u5217\u65b9\u5411, Vertical\u662f\u5782\u76f4<br \/>\n\u5728StackPanel\u5167\u90e8\u7684\u7269\u4ef6Margin=&#8221;10,2,0,1&#8243; \u7684Margin\u9806\u5e8f\u662f\u5de6, \u4e0a, \u53f3, \u4e0b.<\/p>\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">\n<p class=\"Code\" style=\"margin: 0in 0in 0pt;\">\n","protected":false},"excerpt":{"rendered":"<p>\u5728SilverLight\u4e2d\u7528\u4f86\u898f\u5283\u6574\u500b\u7248\u9762Layout\u7684Control\u4e3b\u8981\u6709\u4e09\u7a2e: Grid: \u5c31\u50cfTable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[47,48,46],"class_list":["post-66","post","type-post","status-publish","format-standard","hentry","category-silverlight-20","tag-grid","tag-layout-control","tag-stackpanel"],"_links":{"self":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66"}],"version-history":[{"count":0,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions"}],"wp:attachment":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}