wpf-controls

Using BackgroundWorker with ProgressBar in WPF

你离开我真会死。 提交于 2019-12-18 05:14:09
问题 Hi i have an App where one of the jobs will be convert an Excel and pass all the records to the DB. So this takes a little time because it's more than 7000 rows that i will get and insert into the DB. So because this job takes a little time, more than 3 minutes, I'd like to use a ProgressBar to report progress of this job. So if i am doing this Job in Class that i have created, how can i use the backgroundWorker to report the progress to the progessBar in my case? My objective is be accurate

BringToFront in WPF

非 Y 不嫁゛ 提交于 2019-12-18 04:34:18
问题 I need to bring to front a custom control in WPF. pseudoCode OnMouseDown() { if (this.parent != null) this.parent.BringToFront(this); } I know, I know that there are a ZIndex , but still don't understand how to replace the simple WinForm BringToFront to parent.SetZIndex(this, ?MaxZIndex(parent)? + 1) ? Perhaps there is a better way of doing it in the such a cool thing like WPF?!.. 回答1: Here is an extension function that adds the method BringToFront functionality to all FrameworkElements that

Expander button on the right side: how to do it?

末鹿安然 提交于 2019-12-18 04:07:09
问题 i want to position the Expander button on the right side of the label. How to do this? 回答1: You can also set the FlowDirection to RightToLeft , but that may cause other problems. For example it also changes the flow direction for the content of the expander so you may need to set it back. <Expander FlowDirection="RightToLeft"> <StackPanel FlowDirection="LeftToRight"> </StackPanel> </Expander> 回答2: You must restyle the control's template. Here's an example: http://patconroy.wordpress.com/2008

WPF: On Mouse hover on a particular control, increase its size and overlap on the other controls

China☆狼群 提交于 2019-12-17 19:28:24
问题 I wish to increase the size of a control whenever the user hovers the mouse. The size increase should not readjust the other controls, rather the current control should overlap the neighboring controls as is the case with google search (images tab) shown below: The image with red border overlaps the other images. 回答1: You could use ScaleTransform in RenderTransform on IsMouseOver. If you want the Scaling to be done from the Center of the Control you can use RenderTransformOrigin="0.5,0.5" .

Animate Expander in WPF

自古美人都是妖i 提交于 2019-12-17 19:27:35
问题 How to animate the expanded and collapsed actions of a Wpf expander control? 回答1: I've found this article on Code Project : Read Here The author creates his own SimpleExpander Template, then adds a stretch out animation to it. He even added a nifty rotating arrow to it. 回答2: I created a style based on msdn Style and the point in this answer: <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml

Set Style for all elements inside ContentPresenter

左心房为你撑大大i 提交于 2019-12-17 18:58:31
问题 I overrided the template of wpf expander. The header has ContentPresenter <ContentPresenter x:Name="HeaderContent" Grid.Column="1" Margin="0,0,4,0" HorizontalAlignment="Left" VerticalAlignment="Center" RecognizesAccessKey="True" SnapsToDevicePixels="True" > <ContentPresenter.Resources> <Style BasedOn="{StaticResource Expanderheader-Naming}" TargetType="{x:Type TextBlock}" /> </ContentPresenter.Resources> </ContentPresenter> Where I tried to add my style for all TextBlocks inside. My style

Adding children to UserControl

会有一股神秘感。 提交于 2019-12-17 17:27:30
问题 My task Create a UserControl which should be able to contain any visual child which is available in WPF, the children are displayed in a container which is a child of the UserControl . My Problem I can't manage to get the children displayed correctly in my container, i tried serval ways and did not find a way which works in the designer. I also tried to use ContentControl but nothing gets displayed. My approaches First i found this link and i tried it with some variations. I managed to

Textbox value changed

血红的双手。 提交于 2019-12-17 17:03:09
问题 Is it possible to know if any of the textbox values have changed in the application. I have around 30 textboxes and I want to run a part of code only if, any of the textboxes value has changed out of the 30. Is there a way I can know that. 回答1: Each text box will raise an event TextChanged when it's contents have changed. However, that requires you to subscribe to each and every event. The good news is that you can subscribe to the event with the same method multiple times. The handler has a

How to create an image of a WPF UserControl at runtime

喜夏-厌秋 提交于 2019-12-17 16:38:27
问题 I've created a WPF application which has a Canvas on which I place UserControls which are moveable and resizeable by the user (just like a Windows-Window). Now I have detected that this can be very slow on older PC's which is a problem. As a solution I thought about generating a graphic showing the UserControl and show this while resizing/dragging the Control, to prevent WPF from recalculating all Elements permanently. The only problem is that I have no idea how to generate this image. Is

Can I use NotifyIcon in WPF?

我是研究僧i 提交于 2019-12-17 16:33:10
问题 I want to minimizing application to system tray using WPF. Is "NotifyIcon" is the only way to achieve this result? If yes, which namespace is required for using "NotifyIcon" in WPF? If possible with "NotifyIcon",please provide some hint, how can I use that in my Mainwindow? My main window is, public partial class MonthView : MetroWindow { public DateTime SelectedDate { get; set; } public MonthView() { InitializeComponent(); calMain.DisplayDate = DateTime.Today; Globals._globalController = new