ItemsControlを使ってCanvasにLineを書いています。CanvasにLineの他に円やTextBlockなど複数種類の図形を描画したい場合にはXAMLは
どの様に書いたら良いのでしょうか?
よろしくお願いします。
<ScrollViewer x:Name="scrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <ItemsControl x:Name="itemsControl" ItemsSource="{Binding Path=Lines}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas Background="White" Width="10000" Height="10000" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Line X1="{Binding X1}" Y1="{Binding Y1}" X2="{Binding X2}" Y2="{Binding Y2}" Stroke="{Binding LineColor}" StrokeThickness="3" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ScrollViewer>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/25 15:24