wpf-positioning

Z order in between Image and InkPresenter

ⅰ亾dé卋堺 提交于 2020-01-25 04:04:49
问题 I have this CustomControl which contains an InkPresenter and an Image . The image has an AdornerDecorator as I plan to add an adorner to the image later on. I have set the Canvas.ZIndex of the Image to be higher than the InkPresenter so that the InkPresenter will be drawn over the Image. The problem is that when I try to collect and display ink from the InkPresenter the strokes are drawn underneath the image. (I have used to check the visual tree using Snoop and the InkPresenter is above the

How to add children of an ItemsControl where the children should decide their own position in Wpf?

耗尽温柔 提交于 2019-12-24 05:57:46
问题 I am using a wpf slider to display the time line in a video player. I need to add an ItemControl of some sort on top of this so that I can add buttons on the time line on certain positions in the time line (the buttons will hold their own position relative to the parent ItemsControl). What ItemsControl container should I use where I can add child elements that know their own position (based on their timecode)? I have looked at the different ItemsControls in Wpf, and it looks like all of them

How to add children of an ItemsControl where the children should decide their own position in Wpf?

时光怂恿深爱的人放手 提交于 2019-12-24 05:57:03
问题 I am using a wpf slider to display the time line in a video player. I need to add an ItemControl of some sort on top of this so that I can add buttons on the time line on certain positions in the time line (the buttons will hold their own position relative to the parent ItemsControl). What ItemsControl container should I use where I can add child elements that know their own position (based on their timecode)? I have looked at the different ItemsControls in Wpf, and it looks like all of them

How can I position ViewModels in an ItemsControl

纵然是瞬间 提交于 2019-12-19 11:16:12
问题 My mainwindow ViewModel has an ObservableCollection of ViewModels, called ViewModels. The Mainwindow XAML has an ItemsControl with ItemsSource bound to ViewModels. When I have <ItemsControl ItemsSource="{Binding ViewModels}" /> The Views associated with each ViewModel in the collection are rendered one below the other. The Views are UserControls, displaying dataGrids. How can I position them in a customizable way, for example such that VM1 is on the left, and VM2 and VM3 are stacked one on

Changing the start up location of a WPF window

烈酒焚心 提交于 2019-11-30 01:14:26
I'd like to have a WPF window open in the top right part of the screen. Right now I can achieve that by opening the window and then moving it (via movewindow in user32.dll). However, this approach means the window opens in it's default location, fully loads, and then moves to the top right. How could I do I change it so that I could specify the window's initial position and size? Just set WindowStartupLocation, Height, Width, Left, and Top in xaml: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com

How to center an element in wpf canvas

耗尽温柔 提交于 2019-11-28 19:17:39
How can I center an element in wpf canvas using attached properties? Something like this. double left = (Canvas.ActualWidth - element.ActualWidth) / 2; Canvas.SetLeft(element, left); double top = (Canvas.ActualHeight - element.ActualHeight) / 2; Canvas.SetTop(element, top); I came across this post, because I was searching for a way to center an element within a Canvas in XAML only, instead of using Attached Properties. Just in case, you came for the same reason: <Canvas x:Name="myCanvas"> <Grid Width="{Binding ActualWidth, ElementName=myCanvas}" Height="{Binding ActualHeight, ElementName

How to center an element in wpf canvas

吃可爱长大的小学妹 提交于 2019-11-27 12:11:32
问题 How can I center an element in wpf canvas using attached properties? 回答1: Something like this. double left = (Canvas.ActualWidth - element.ActualWidth) / 2; Canvas.SetLeft(element, left); double top = (Canvas.ActualHeight - element.ActualHeight) / 2; Canvas.SetTop(element, top); 回答2: I came across this post, because I was searching for a way to center an element within a Canvas in XAML only, instead of using Attached Properties. Just in case, you came for the same reason: <Canvas x:Name=

Changing the start up location of a WPF window

假装没事ソ 提交于 2019-11-27 11:53:50
问题 I'd like to have a WPF window open in the top right part of the screen. Right now I can achieve that by opening the window and then moving it (via movewindow in user32.dll). However, this approach means the window opens in it's default location, fully loads, and then moves to the top right. How could I do I change it so that I could specify the window's initial position and size? 回答1: Just set WindowStartupLocation, Height, Width, Left, and Top in xaml: <Window x:Class="WpfApplication1

Get Absolute Position of element within the window in wpf

蓝咒 提交于 2019-11-26 12:24:40
I would like to get the absolute position of an element in relation to the window/root element when it is double clicked. The element's relative position within it's parent is all I can seem to get to, and what I'm trying to get to is the point relative to the window. I've seen solutions of how to get a the point of an element on the screen, but not in the window. I think what BrandonS wants is not the position of the mouse relative to the root element, but rather the position of some descendant element. For that, there is the TransformToAncestor method: Point relativePoint = myVisual

Get Absolute Position of element within the window in wpf

社会主义新天地 提交于 2019-11-26 02:57:08
问题 I would like to get the absolute position of an element in relation to the window/root element when it is double clicked. The element\'s relative position within it\'s parent is all I can seem to get to, and what I\'m trying to get to is the point relative to the window. I\'ve seen solutions of how to get a the point of an element on the screen, but not in the window. 回答1: I think what BrandonS wants is not the position of the mouse relative to the root element, but rather the position of