悬赏园豆:50
[已关闭问题]
<pre>xaml<br /><div class="cnblogs_code"><pre><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF;"><</span><span style="color: #800000;">controlsToolkit:WrapPanel </span><span style="color: #FF0000;">x:Name</span><span style="color: #0000FF;">="myListBox"</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">controlsToolkit:WrapPanel.DataContext</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">DataTemplate</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">Grid </span><span style="color: #FF0000;">Width</span><span style="color: #0000FF;">="80"</span><span style="color: #FF0000;"> Height</span><span style="color: #0000FF;">="60"</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">Image </span><span style="color: #FF0000;">Source</span><span style="color: #0000FF;">="{Binding imgurl}"</span><span style="color: #FF0000;"> Height</span><span style="color: #0000FF;">="47"</span><span style="color: #FF0000;"> HorizontalAlignment</span><span style="color: #0000FF;">="Left"</span><span style="color: #FF0000;"> VerticalAlignment</span><span style="color: #0000FF;">="Top"</span><span style="color: #FF0000;"> Width</span><span style="color: #0000FF;">="59"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">TextBlock </span><span style="color: #FF0000;">Text</span><span style="color: #0000FF;">="{Binding shuliang}"</span><span style="color: #FF0000;"> TextWrapping</span><span style="color: #0000FF;">="Wrap"</span><span style="color: #FF0000;"> Height</span><span style="color: #0000FF;">="13"</span><span style="color: #FF0000;"> VerticalAlignment</span><span style="color: #0000FF;">="Top"</span><span style="color: #FF0000;"> Margin</span><span style="color: #0000FF;">="0,46,0,0"</span><span style="color: #FF0000;"> HorizontalAlignment</span><span style="color: #0000FF;">="Left"</span><span style="color: #FF0000;"> Width</span><span style="color: #0000FF;">="59"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">TextBlock </span><span style="color: #FF0000;">Text</span><span style="color: #0000FF;">="{Binding danwei}"</span><span style="color: #FF0000;"> Height</span><span style="color: #0000FF;">="13"</span><span style="color: #FF0000;"> HorizontalAlignment</span><span style="color: #0000FF;">="Left"</span><span style="color: #FF0000;"> Margin</span><span style="color: #0000FF;">="47,0,0,0"</span><span style="color: #FF0000;"> VerticalAlignment</span><span style="color: #0000FF;">="Top"</span><span style="color: #FF0000;"> Width</span><span style="color: #0000FF;">="12"</span><span style="color: #FF0000;"> TextWrapping</span><span style="color: #0000FF;">="Wrap"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">DataTemplate</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">controlsToolkit:WrapPanel.DataContext</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br /> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">controlsToolkit:WrapPanel</span><span style="color: #0000FF;">></span></pre>
</div>
<br /><br />cs<br />
<div class="cnblogs_code">
<pre><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> Blog<br />{<br /> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> String imgurl { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }<br /> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> String shuliang { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }<br /> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> String danwei { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }<br />}<br /><br /></span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> UserControl_Loaded3(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> sender, RoutedEventArgs e)<br />{<br /> List</span><span style="color: #000000;"><</span><span style="color: #000000;">Blog</span><span style="color: #000000;">></span><span style="color: #000000;"> blogs </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> List</span><span style="color: #000000;"><</span><span style="color: #000000;">Blog</span><span style="color: #000000;">></span><span style="color: #000000;">()<br /> {<br /> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Blog(){imgurl</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">http://www.021yc.com/021jiaji/image/2007331155343586.jpg</span><span style="color: #800000;">"</span><span style="color: #000000;">,shuliang </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">27</span><span style="color: #800000;">"</span><span style="color: #000000;">, danwei</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">a</span><span style="color: #800000;">"</span><span style="color: #000000;">},<br /> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Blog(){imgurl</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">http://www.021yc.com/021jiaji/image/2007331155343586.jpg</span><span style="color: #800000;">"</span><span style="color: #000000;">,shuliang </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">30</span><span style="color: #800000;">"</span><span style="color: #000000;">, danwei</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">b</span><span style="color: #800000;">"</span><span style="color: #000000;">},<br /> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Blog(){imgurl</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">http://www.021yc.com/021jiaji/image/2007331155343586.jpg</span><span style="color: #800000;">"</span><span style="color: #000000;">,shuliang </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">38</span><span style="color: #800000;">"</span><span style="color: #000000;">, danwei</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">c</span><span style="color: #800000;">"</span><span style="color: #000000;">},<br /> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Blog(){imgurl</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">http://www.021yc.com/021jiaji/image/2007331155343586.jpg</span><span style="color: #800000;">"</span><span style="color: #000000;">,shuliang </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">29</span><span style="color: #800000;">"</span><span style="color: #000000;">, danwei</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">d</span><span style="color: #800000;">"</span><span style="color: #000000;">} <br /> }; <br /> </span><span style="color: #008000;">//</span><span style="color: #008000;">myListBox.ItemsSource = blogs;</span><span style="color: #008000;"><br /></span><span style="color: #000000;"> myListBox.DataContext </span><span style="color: #000000;">=</span><span style="color: #000000;"> blogs;<br />}<br /><br /></span></pre>
</div>
<br /><br />没有显示任何信息,是不是绑定有问题? </pre>
凝决
|
初学一级
|
园豆:
150
提问于:2009-08-17 15:32