■83384 |
WPFにて、想定デザインの実現方法がわからない |
□投稿者/ P2AP -(2017/03/20(Mon) 11:20:55)
| 分類:[.NET 全般]
いつもお世話になっております。 環境:C#+VisualStudio2015Blend
以下のキャプチャのように、DockPanelの中にCheckBox、Button、RichTextBoxが入ったものを1セットとして、 それを動的に生成したいです。
キャプチャ:https://gyazo.com/2b5c06c9954176f3a0d13ef7df70c99a XAML: <DockPanel Height="49" LastChildFill="False"> <CheckBox x:Name="checkBox" Content="CheckBox"/> <Button x:Name="button" Content="Button" Width="75"/> <RichTextBox x:Name="richTextBox" DockPanel.Dock="Top" Margin="0,0,397.603,0"> <FlowDocument> <Paragraph> <Run Text="RichTextBox"/> </Paragraph> </FlowDocument> </RichTextBox> </DockPanel>
実現の為、以下のようなテストコードを記述しました。 キャプチャ:https://gyazo.com/fdc17caee7228a3beb1442a7c93e173a Source: var list = new List<DockPanel>(); foreach (var item in listRssRow.Select((data, count) => new { data, count })) { list.Add(new DockPanel() { Height = 20, Width = 300 }); list[item.count].Children .Add(new RichTextBox() { Document = new FlowDocument(new Paragraph(new Run(item.data.Title))) , Width = 300 , Height = 30 , Foreground = new SolidColorBrush(Colors.White) }); list[item.count].Children .Add(new Button() { Content = "Test" , Width = 300 , Height = 30 , Foreground = new SolidColorBrush(Colors.White) , Background = new SolidColorBrush(Colors.White) }); Application.Current.Dispatcher.Invoke(new Action(() => { this.spMain.Children.Add(list[item.count]); }));
質問は以下です。 1.RichTextBoxがDockPanelのどこに位置するのかを指定する方法。 DockPanel.DockというプロパティがあるのはXAMLを見てわかりましたが、RichTextBox型で扱う?にはどのような方法があるでしょう。 2.Buttonが描写されないが、不足している記述があるのでしょうか?
指導して頂けたら幸いです。以上です。
|
|