uielement

How to clone UIElement in WinRT XAML C#?

♀尐吖头ヾ 提交于 2019-11-30 14:17: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 anyone tell me how can I clone the existing UserControl in my canvas to itself ? Dr Herbie I have written

Absolute coordinates of UIElement in WinRT

蹲街弑〆低调 提交于 2019-11-30 03:15:29
问题 Cannot find a way to locate absolute position of an UIElement in Metro style app. Anybody know the solution? (the context: I want a Popup to be shown next to the button called it) 回答1: This should work... private void Button_Click(object sender, RoutedEventArgs e) { var button = sender as Button; var ttv = button.TransformToVisual(Window.Current.Content); Point screenCoords = ttv.TransformPoint(new Point(0, 0)); } 来源: https://stackoverflow.com/questions/12161584/absolute-coordinates-of

Is there any unique identifier for wpf UIElement?

给你一囗甜甜゛ 提交于 2019-11-29 06:54:24
For logging user actions in my WPF forms, I added some global event handlers I want to log exactly which control fire the event, is there some unique identifier for a wpf UIElement like ClientId in ASP.Net? Jason Ridge Why don't you use the Hash Code. You can compare the values to make sure they are the same object, and its easy to get them with .GetHashCode() Edit Obviously this is different every time you run the program, so actually this is prolly a bad idea, unless you want to update the log each time the process is logged. Still possible though I mean you could store a hash value for each

Is there any unique identifier for wpf UIElement?

£可爱£侵袭症+ 提交于 2019-11-28 00:23:38
问题 For logging user actions in my WPF forms, I added some global event handlers I want to log exactly which control fire the event, is there some unique identifier for a wpf UIElement like ClientId in ASP.Net? 回答1: Why don't you use the Hash Code. You can compare the values to make sure they are the same object, and its easy to get them with .GetHashCode() Edit Obviously this is different every time you run the program, so actually this is prolly a bad idea, unless you want to update the log

WPF - Get size of UIElement in Memory?

荒凉一梦 提交于 2019-11-27 06:06:01
问题 Is there a way to get the size of a UIElement that resides in memory and has not yet been rendered? I currently have a routine that creates a Grid from a DataTable and then adds the Grid into a FixedDocument . I need to know the size of the Grid because I want to automatically switch from Portrait to Landscape if needed; or even change the FontSize of the grid. 回答1: You need to force a render of the item, or wait for the item to be rendered. You can then use the ActualHeight and ActualWidth