wpf-controls

Dragging selected Item along with the mouse in WPF

扶醉桌前 提交于 2019-12-10 18:04:02
问题 I am using the following code for performing Drag & Drop in my StackPanel Childran, XAML <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="601" Width="637"> <StackPanel Name="sp" AllowDrop="True" Background="SkyBlue" PreviewMouseLeftButtonDown="sp_PreviewMouseLeftButtonDown" PreviewMouseLeftButtonUp="sp_PreviewMouseLeftButtonUp" PreviewMouseMove="sp

Parent TreeView Item ghost selected event!

孤街醉人 提交于 2019-12-10 17:35:50
问题 I have a TreeView that launches a new window when each of its TreeViewItems Selected event is raised. <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <TreeView Name="treeView1"> <TreeViewItem Header="Root"> <TreeViewItem Header="Parent" Selected="ParentTreeViewItem_Selected"> <TreeViewItem Header="Child" Selected="TreeViewItem

Multiple instances of a wpf user control all use the same viewmodel

泪湿孤枕 提交于 2019-12-10 16:46:52
问题 I have an app that when I click a button loads a new tabitem with a usercontrol. This works fine, but... When I click the Add button again, another tabitem is added with a new instance of the usercontrol. Here comes the problem. When I add some data in tab1 and switch to tab2, I also see the entered data there. How is this possible? I use a new viewmodel for each usercontrol so how can both usercontrols on tab1 and tab2 show the same data. It will probably be something stupid, but I can't

DependencyProperty and WPF Designer

五迷三道 提交于 2019-12-10 16:39:52
问题 class MyLine : Shape { public static readonly DependencyProperty X11Property; public static readonly DependencyProperty X22Property; public static readonly DependencyProperty Y11Property; public static readonly DependencyProperty Y22Property; static MyLine() { X11Property = DependencyProperty.Register("X11", typeof(double), typeof(MyLine), new UIPropertyMetadata(double.NaN)); X22Property = DependencyProperty.Register("X22", typeof(double), typeof(MyLine), new UIPropertyMetadata(double.NaN));

Binding the displayed pattern (Path) to data model/How to make paths the same dimensions

笑着哭i 提交于 2019-12-10 15:46:05
问题 Background [Feel free to skip this] I'm building a program that deals with horses, their owners, and the owner's racing colours (silks). This question is about a UserControl , called SilksControl that acts as a view for the JockeySilks . To represent the silks I use the following class of enums: public class JockeySilks { public BodyPatterns BodyPattern { get; set; } public Colour BodyColour1 { get; set; } public Colour BodyColour2 { get; set; } public SleevePatterns SleevePattern { get; set;

Does WPF use native Windows contols?

偶尔善良 提交于 2019-12-10 15:44:18
问题 Does it perform drawing by itself, or uses the native UI components provided by Windows in any way? 回答1: WPF sort of uses native controls because WPF is the new native way to render controls in Windows - what you consider native is legacy win32, and basically slowly on the way to history. MS did a lot of optimization in DirectX to allow WPF efficiently to render using the GPU. This is a new "native" interface that is also used to render the Vista upward AERO interface. WPF goes directly to a

Allow users to resize Expander in WPF

China☆狼群 提交于 2019-12-10 15:39:11
问题 I have a lot of C# and WinForms experience but am a newbie to WPF. I have a Window with an Expander which expands downward. Much like the question box I'm currently typing in, I'd like users to be able to dynamically resize the Expander by clicking over a glyph at the bottom (like this question box) and dragging the expander to the desired size. Can anyone provide the XAML (and any additional code) to do this? This is what I have so far: <Expander Header="Live Simulations" Name=

Windows 8 WPF progress bars don't have glow animation

廉价感情. 提交于 2019-12-10 15:36:50
问题 The progress bars in Windows Forms applications have the standard "shine" animation, but when I try to add a progress bar in WPF I don't get such a thing by default. How do we get this back with WPF in Windows 8? Windows Forms WPF 回答1: It's a rather bizzare fix, but you need to enable Windows Forms styles in your application to use the "gloss." Here's how I did it. Add a reference in your project to System.Windows.Forms Go to the Project settings page and click View Application Events Add a

Forcing MediaElement to Release Stream after playback

核能气质少年 提交于 2019-12-10 14:52:43
问题 I am creating an audio recorder control, with playback functionality. I use the media element to play the recorded audio like this: using (var storage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()) { using (System.IO.Stream stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream(filePath, System.IO.FileMode.Open, storage)) { player.SetSource(stream); } } The problem i am facing is that when I use media element to play the recorded audio. The Stream is

Difference between Calendar & Date Picker control in WPF?

狂风中的少年 提交于 2019-12-10 14:37:55
问题 Difference between Calendar & Date Picker control in WPF? Is there any criteria of choosing the either of them? Thank you. 回答1: Per the DatePicker documentation: The DatePicker control allows the user to select a date by either typing it into a text field or by using a drop-down Calendar control. Many of a DatePicker control's properties are for managing its built-in Calendar, and function identically to the equivalent property in Calendar. [snip] For more information, see Calendar. The