wpf-controls

Run vs. Content vs. Text in WPF

余生颓废 提交于 2020-07-28 08:58:47
问题 In a WPF (or even a Windows 8 or 8.1 application) you have three possible ways to add a text in a control. Run element inside TextBlock element <TextBlock> <Run>My text</Run> </TextBlock> Text property as attribute of TextBlock element <TextBlock Text="My text" /> Text property as element inside TextBlock element <TextBlock> <TextBlock.Text>my text</TextBlock.Text> </TextBlock>` What are the differences between these three approaches? And why you must use Text for a TextBlock and Content for

WPF - is there a way to remove specific child from Canvas.Children?

五迷三道 提交于 2020-07-19 03:51:09
问题 I am working on a charting control where I am plotting the "analysis range," which is just two vertical lines on the chart. A problem arises when I want to change the analysis range, because I don't know how to remove only the two analysis range lines, so I end up clearing the chart and plotting the actual data values and whatnot again. Is there a way to tag these UI elements (i.e. analysis range is a gridline UI element) so that I can remove them specifically? I suppose I could save the