uielement

How can I get the parent Popup for a UIElement?

放肆的年华 提交于 2019-12-22 21:13:32
问题 I have two questions on markup below: <Popup> <Button x:Name="button"/> </Popup> Why does VisualTreeHelper.GetParent(button) return null? How can I get the parent Popup for UIElement ? 回答1: Because the Button is only added to the visual tree when the popup is being displayed. Hmm... tricky ... Edit There is an assumption in the following that your popup is defined in the XAML of UserControl so whilst its child may not be in the visual tree the popup primitive control is. Re-using some code I

UIElement to image file (WP7)

孤街醉人 提交于 2019-12-19 17:27:26
问题 I have a StackPanel which includes a few Rectangles that I want put to an image file (e.g. PNG). I'm developing this on Windows Phone 7 and most of the information I found on the internet wasn't applicable (I think) to WP7. I think the System.Windows.Media.Imaging namespace is the key to this, but I'm not sure where to begin. This is basically what I want to do: StackPanel stack = new StackPanel(); List<Rectangle> recList = new List<Rectangle>(); add some rectangles to recList foreach(var x

How make a Screenshot of UIElement in WPF

你说的曾经没有我的故事 提交于 2019-12-19 10:11:56
问题 I have a problem with creating a screenshot of a scatterview. My screenshot always contains a black frame. Here's my XAML-Code: <s:SurfaceWindow xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="http://schemas.microsoft.com/surface/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="MakeScreenshots

WPF ListBox - Getting UIElement instead of of SelectedItem

血红的双手。 提交于 2019-12-19 05:13:17
问题 I created a ListBox that has a DataTemplate as Itemtemplate . However, is there an easy way to access the generated UIElement instead of the SelectedItem in codebehind? When I access SelectedItem , I just get the selected object from my ItemsSource collection. Is there a way to access the UIElement (ie. the element generated from the DataTemplate together with the bound object)? 回答1: You are looking for the ItemContainerGenerator property. Each ItemsSource has an ItemContainerGenerator

Any way to save an UIElement created programmatically in an image file?

柔情痞子 提交于 2019-12-19 04:14:19
问题 I'm trying to save an UIElement created programmatically in a JPG/PNG/BMP image in a Windows Phone 8.1 (C#) application. I'm using the class RenderTargetBitmap using the method RenderAsync() but it only works with UI elements created in the XAML code. When I use it on UI elements created directly in C# I have this exception: "System.ArgumentException (Value does not fall within the expected range.)" Am I doing something wrong or this class doesn't allow rendering of UIElement(s) created

How to clone UIElement in WinRT XAML C#?

那年仲夏 提交于 2019-12-18 17:00:06
问题 I have tried this approach first but getting error "Element is already the child of another element" var objClone = new MyImageControl(); objClone = this; ((Canvas)this.Parent).Children.Add(objClone); Then I checked this and this, but XamlWriter and XamlReader is not available in WinRT. I have tried to use MemberwiseClone() but it throws exception, "COM object that has been separated from its underlying RCW cannot be used. System.Runtime.InteropServices.InvalidComObjectException ". So can

How to clone UIElement in WinRT XAML C#?

我的未来我决定 提交于 2019-12-18 16:59:22
问题 I have tried this approach first but getting error "Element is already the child of another element" var objClone = new MyImageControl(); objClone = this; ((Canvas)this.Parent).Children.Add(objClone); Then I checked this and this, but XamlWriter and XamlReader is not available in WinRT. I have tried to use MemberwiseClone() but it throws exception, "COM object that has been separated from its underlying RCW cannot be used. System.Runtime.InteropServices.InvalidComObjectException ". So can

I want to drag an image from a Silverlight UIElement and drop it on the users Desktop or Windows Explorer

不打扰是莪最后的温柔 提交于 2019-12-13 12:06:41
问题 I have a Silverlight control containing an image. I want the user to be able to drag the image out of the Silverlight application and drop it anywhere they would be able to drop an image. For example, to the Desktop or to a PowerPoint slide or Word document. Everything that I have read thus far says it cannot be done but I find that hard to believe. I'm very new to Silverlight and RIA development so any help would be much appreciated. Below is the code sample in my WinForm Form but the drag

Storyboard ui elements don't appear in Xcode 5

北城以北 提交于 2019-12-13 05:16:18
问题 I have transitioned my iPad application from iOS 6 to iOS 7 and I had to turn off auto layout or the whole application would crash when I selected to view the storyboard. Now that I can view it, all the uielements don't appear in the each storyboard screen. The screens are there but they are blank (white). The editor shows that they are there but I cannot view them at all. 回答1: Try changing the width and height/ x and y coordinate of the views. That fixed the same problem for me. 来源: https:/

Use UIElements as ItemsSource of ListBox in Silverlight

懵懂的女人 提交于 2019-12-13 03:42:51
问题 I've noticed that if you have anything deriving from UIElement as items in a ListBox in Silverlight it renders the object as is and isn't paying any attention to settings of DisplayMemberPath and/or ListBox.ItemTemplate . For example if you have XAML like this: <ListBox Width="200" Height="300" DisplayMemberPath="Tag"> <TextBlock Tag="tag1">text1</TextBlock> <TextBlock Tag="tag2">text2</TextBlock> <TextBlock Tag="tag3">text3</TextBlock> </ListBox> In Siverlight this produces a ListBox with