uielement

Copy UI element with adorner

淺唱寂寞╮ 提交于 2019-12-12 11:00:48
问题 I am working on taking screenshot of UI Element (WPF) in various size and i'm able to achieve this using "RenderTargetBitmap. But the UIElement which has an Adorner part is not coming while take copy. What should i do to achieve this. Any reference or code snippet? 回答1: As far as I know, elements don't have direct references to their adorners. Adorners do reference their element through AdornedElement though, so you could search for adorners assigned to your element like this: var layer =

How can you get the parent of a UIElement?

北城余情 提交于 2019-12-12 07:56:59
问题 Ok, I know that FrameworkElement , which is a direct subclass of UIElement , has a Parent property, but Panels have children of type UIElement , not FrameworkElement (Children is of type UIElementCollection ) which seems it would mean you can add UIElement s directly to a Panel. That said, if you have a UIElement and want to see if it has a parent that's a panel, the only way I know how to test this is with the VisualTreeHelper , but that's the visual tree, not the logical tree. (At least we

How to use UIElement[] CreateLabels method in NumericLabelProviderBase class to insert label or text in a point inside plotter

三世轮回 提交于 2019-12-12 05:07:38
问题 I'm tring to override CreateLabels to insert labels or text in specific points in plotter chart but I need a help in: 1. what does the parameter ( ITicksInfo<double> ticksInfo ) mean and what should I send to it 2. how to use the return value to add labels to already defined Axis like _stringaxis.LabelProvider or if there is simpler way to add text in a point please tell, Many thanks. 回答1: Just found the easiest way to add a nice label inside the chart. CenteredTextMarker label = new

How to change a value of UIElement

喜夏-厌秋 提交于 2019-12-12 02:53:27
问题 I have a WPF application and Canvas in there. In Canvas I have a Rectangle. How can I change his properties, like Height or Width while program is already processing? Something like: int index = 0; var childByIndex = canvas.Children[index]; childByIndex.SetValue(Height, 15); 回答1: You will have to tell which dp of which type you want to set like below: ((Rectangle)canvas.Children[index]).SetValue(Rectangle.HeightProperty, 15.0); 回答2: The easiest way would be to give your rectangle a name in

Adding text to WPF Line

北战南征 提交于 2019-12-12 01:54:17
问题 How do I add text to a Line UIElement? I would like to have the text placed in the middle of the line. <Line Stroke="Black" X1="{Binding From.CanvasCenterX}" Y1="{Binding From.CanvasCenterY}" X2="{Binding To.CanvasCenterX}" Y2="{Binding To.CanvasCenterY}" StrokeThickness="2" /> Is this possible? 回答1: The following XAML code adds text to a Line UIElement. In this example the text is presented by a <TextBlock... /> . The text is centered at the Line, but this can easily be changed by the

multiple geometry clips on a UIElement

落爺英雄遲暮 提交于 2019-12-11 14:55:09
问题 I am using C#, Silverlight, Visual Studio for Windows Phone 7. Is there a way to give a UIElement multiple Geometry clips? Something equivalent to: Path myPath = new Path(); myPath.Data = myRectangle; // say of size 100x100 myPath.Clip = myClipRect; // smaller rectangle, say of size 20x20, located at (0,0) myPath.Clip = myClipEllipse; // circle of radius 30, centered on myRectangle Right now, myClipEllipse will override myClipRect in myPath.Clip, so only myClipEllipse will be displayed. I'm

Get UIElement children from multiple parent

。_饼干妹妹 提交于 2019-12-11 11:25:13
问题 I have a StackPanel with some WrapPanel . inside each WrapPanel located two element: <StackPanel FlowDirection="RightToLeft" Grid.Column="2" Grid.Row="1" Name="check_boxes_layout"> <WrapPanel> <CheckBox Name="chk1" Checked="Checked_Changed" Unchecked="Unchecked"></CheckBox> <Rectangle Width="50" Fill="Red" Name="rec1" Margin="10 2 2 2"/> </WrapPanel> <WrapPanel> <CheckBox Name="chk12" Checked="Checked_Changed" Unchecked="Unchecked"></CheckBox> <Rectangle Width="50" Fill="Blue" Name="rec2"

How to copyclone a UIElement and keep the layout/render information?

别说谁变了你拦得住时间么 提交于 2019-12-11 04:16:53
问题 I wish to copy a complex data-bound UIElement but keep the Binding, Layout and Rendering information from the original UIElement. Creating a new UIElement seems inefficient since I would have to do another complete Binding/Measure/Arrange/Render pass. The closest I've got so far is to create a new DrawingVisual , open it for rendering, and DrawDrawing using the source UIElement DrawingGroup . DrawingVisual dv = new DrawingVisual(); DrawingGroup dg = VisualTreeHelper.GetDrawing(SourceElement);

Dynamic and Immutable UIElement Arrays

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 03:16:29
问题 I have a WrapPanel that contains multiple Canvas of the same size. Each Canvas has some UIElement s (i.e. TextBox , TextBlock , Button s etc) as children. The creation of each Canvas (including its UIElement children) and the number of Canvas to be created are all done in run-time code behind (no XAML). Initially I did the following, which works: // declare as class properties, so all function can access them WrapPanel wp = new WrapPanel(); Canvas[] cv = new Canvas[500]; TextBox[] tb = new

Binding on a Non-UIElement

蹲街弑〆低调 提交于 2019-12-11 02:16:48
问题 I am having problems with Binding. Since RelativeSource needs the visual tree to travel up and find the desired Ancestor, you are only allowed to use it on an UIElement but I am trying to do a RelativeSource binding on an Non-UIElement, such as is a ValidationRule, which as you all know isnt inside the VisualTree nor its UIElement . As you can expect the binding breaks. RelativeSource couldn't be found because like i said there is no VisualTree or LogicalTree available. I need to make it work