wpf-controls

How do I bind DateTime as DepedencyProperty of a DependencyObject so that it will show up in a textbox?

瘦欲@ 提交于 2019-12-13 04:28:12
问题 I want to learn how to use Dependency Objects and Properties. I have created this class, public class TestDependency : DependencyObject { public static readonly DependencyProperty TestDateTimeProperty = DependencyProperty.Register("TestDateTime", typeof(DateTime), typeof(TestDependency), new PropertyMetadata(DateTime.Now)); public DateTime TestDateTime { get { return (DateTime) GetValue(TestDateTimeProperty); } set { SetValue(TestDateTimeProperty, value); } } } The window class is like this

Dragging a window in WPF using DragMove method and click handler on the same button

只谈情不闲聊 提交于 2019-12-13 04:09:16
问题 I need a button for two purposes: - Users can drag the application's window using the button - Users can simply click the button to toggle visibility of some other element in the window. The button is a PNG image. I am trying to do it in the following way: XAML: <Button Name="toggleButton" Click="toggleButton_Click" Canvas.Left="177" Canvas.Top="0"> <Button.Template> <ControlTemplate> <Image Source="/FootballRssReader;component/images/ball.png" MouseLeftButtonDown="toggleButton

Navigating to a specific fragment in a flow document from code behind

╄→гoц情女王★ 提交于 2019-12-13 03:32:45
问题 I have a WPF page used as an input form which contains a number of controls on one side, and a flow document reader on the other. I want to set the content of this document reader to a specific part of a flow document which is loaded when the form is loaded, (via a loaded event). I have found an article explaining how to do this, using fragments, but the examples shown are only expressed in XAML. In my case I need to update the document property of the flow document reader when the user gives

How to bind a Control.Property to a property in the code-behind?

霸气de小男生 提交于 2019-12-13 03:25:10
问题 I have a TextBox in my WPF window. I have a property in the code behind called Text as well. I want the text property to be bound to the Text property (i.e. when the value changes in the property the textbox value should also be updadated. Thanks 回答1: You have to set the DataContext of the TextBox control (or of any of its parents) to your window: myTextBox.DataContext = this; then in your XAML: <TextBox Text={Binding Text} x:Name="myTextBox"/> 来源: https://stackoverflow.com/questions/1734969

WPF UserControl Dependency Property not working

无人久伴 提交于 2019-12-13 03:03:05
问题 In a WPF project (code below) I have a UserControl of type MyUserControl with a dependency property, called MyOrientation of type Orientation . On the MainWindow I have 2 instances of MyUserControl , where via XAML I set the Orientation property on one to be Horizontal and the other instance to be Vertical . I have made the MyOrientation property a DP as I want the ability to set it directly in XAML as in this example or using a binding. My problem is that when I run the project both

WPF Windows Docking that affects other windows in Maximized mode

。_饼干妹妹 提交于 2019-12-13 02:54:14
问题 I'm writing a WPF project that is effectively a ticker that runs at the bottom of the screen, above the taskbar. I need the ticker to: 1) Reside directly above the taskbar 2) Stay on top of all other windows 3) To continue to do so if the taskbar is set to auto-hide, without obstructing the taskbar 4) Make it so that other windows, which are maximized, don't occupy the space behind the ticker. So it should behave the same way as the task bar, in that it occupies permanent desktop space, which

Question on MVVM pattern on WPF?

淺唱寂寞╮ 提交于 2019-12-13 02:14:49
问题 I have a user control let say UC1 . This user control have viewmodel UC1_vm. In the usercontrol UC1 I have a canvas in which drawing curve logic is implemented. This drawing curve logic is based on the data points property in the view model ( UC1_vm). The data points property inside the view model change with different condition. The generation of data points is written in the View Model. I want to bind the data points property in the view model to the draw curve logic inside the User control

How to set Mouse Cursor in XAML / WPF?

只谈情不闲聊 提交于 2019-12-13 02:12:09
问题 How can I set the Mouse cursor in xaml? What's the use of Cursor property in every control? Please don't answer as Cursor="Arrow" cause this is not working. Only way I can do it right now is from code behind by Mouse.OverrideCursor . Can I do it simply using XMAL? I have a Hierarchy of controls where there is a GridSplitter in between somewhere. I'm trying to set the Cursor to SizeNS but it's set to default as default Arrow . What Should I do? 回答1: In WPF Cursor creates problem when controls

WPF Ribbon Button glowing effects and changing image when hover

痴心易碎 提交于 2019-12-13 00:38:59
问题 Good day. I have a ribbon button with glowing effects when hover. But I wanted also to change the image every time I hover it without losing the glowing effects. Can anyone help me with this? This is what I have so far. <pbwpf:Window.Resources> <Style TargetType="{x:Type my:Ribbon}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type my:Ribbon}"> <StackPanel Orientation="Vertical" Height="750" Background="#111111"> <my:RibbonButton Name="rb_new" Margin="0,40,0,0"

Is it possible to change parent of WPF control

ⅰ亾dé卋堺 提交于 2019-12-12 19:47:04
问题 Is it possible to change the parent of a WPF control? Here is an example: StackPanel stack1 has Button btn1 in it. There is another empty StackPanel stack2. I want to move the btn1 to stack2 programmatically. Thanks for the help. 回答1: You can do this via the StackPanel.Children property: stack1.Children.Remove(btn1); stack2.Children.Add(btn1); 来源: https://stackoverflow.com/questions/17222161/is-it-possible-to-change-parent-of-wpf-control