wpf-controls

ListView ItemContainerStyle Template

回眸只為那壹抹淺笑 提交于 2019-12-08 04:44:50
问题 I created style to be used as my ListView's item template that contains a CheckBox and a TextBlock: <Style x:Key="CheckBoxListStyle" TargetType="{x:Type ListView}"> <Setter Property="SelectionMode" Value="Multiple"></Setter> <Setter Property="ItemContainerStyle"> <Setter.Value> <Style TargetType="{x:Type ListViewItem}" > <Setter Property="Template"> ... The checkbox in the template is bound to the IsSelected property of the list view item: <CheckBox x:Name="itemCheckBox" Width="13" Height="13

Volume Slider CustomControl

一曲冷凌霜 提交于 2019-12-08 04:05:49
问题 i searched the last hours for a customcontrol that looks like this: http://i1-scripts.softpedia-static.com/screenshots/Volume-Slider-10188.png It's like a simple slider, but this growing size to the right side is my problem. I don't know how to do this. Have anyone an idea? greetings 回答1: You can define a geometry that has the shape of a triangle and use that as a OpacityMask of the Track . The Track has a repeat button on the left to decrease the value and on the right to increase it. You

WPF custom control and direct content support

烈酒焚心 提交于 2019-12-08 03:56:21
问题 I am fairly new to WPF, and am a bit stuck, so any help would be appreciated. I am trying to write WPF custom control that encapsulates several elements of functionality that I already having working (i.e sorting, filtering, standard menus, etc.), but in a nice neat package to avoid repetition. Anyway I have created the custom control (based on control), and then have the following in the Generic.Xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns

Changing dynamically created button's background in WPF

送分小仙女□ 提交于 2019-12-08 03:29:25
I have the following code to dynamically create and add a button to a panel: StackPanel topPanel=...; Button button=new Button(); button.Content="New Button "+topPanel.Children.Count; // Set button background to a red/yellow linear gradient // Create a default background brush var bgBrush=new LinearGradientBrush(new GradientStopCollection( new GradientStop[] {new GradientStop(Color.FromRgb(255,255,200),0.5), new GradientStop(Color.FromRgb(255,200,200),0.5)})); // Create a more intense mouse over background brush var bgMouseOverBrush=new LinearGradientBrush(new GradientStopCollection( new

Get element that stole focus before it does in WPF

99封情书 提交于 2019-12-08 03:08:16
问题 To be clearer. I need to know which element stole focus in the focused element LostFocus event. Something like this: I have 3 buttons: A, B and C "Button A" has focus "Button C" is clicked "Button A" LostFocus event is triggered In there I want to know that "Button C" stole the focus (Could've also been "Button B") Let me know if there's a way to accomplish this. Thanks! 回答1: You can always check the FocusManager.GetFocusedElement(dObj) to get the focused element within a given

Passing WPF user control selection to host control

柔情痞子 提交于 2019-12-08 01:54:56
问题 I have a WPF user control with a list box. I want to pass the selected item in the list box to the calling control through binding. How can I achieve this? 回答1: You can expose a new property for SelectedItem on your user control and bind it to the child control ListBox. Code for your user control (I inherited from Control though): public class CustomListControl : Control { static CustomListControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomListControl), new

Simple WPF page selection for multipaged tiff

前提是你 提交于 2019-12-08 01:03:40
问题 I am making a basic Tiff viewer and need to be able to select the page to be viewed. In Winforms I could use selectActiveFrame, so I was wondering if there is a WPF equivalent for this. Thanks! EDIT: In winforms I used System.Drawing.Imaging.FrameDimension in the selectActiveFrame method if that helps at all. 回答1: You can use the TiffBitmapDecoder class to load the image and then use the Frames property to access which tiff frame you like. 来源: https://stackoverflow.com/questions/4546994

How can I make a Rectangle on a canvas which is draggable?

醉酒当歌 提交于 2019-12-07 22:19:21
问题 I have these three functions to trigger the events. I already have a static version of my needs, but I need a dynamically version of it. bool captured = false; double x_shape, x_canvas, y_shape, y_canvas; UIElement source = null; private void MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { source = (UIElement)sender; Mouse.Capture(source); captured = true; x_shape = Canvas.GetLeft(source); x_canvas = e.GetPosition(canvasPreview).X; y_shape = Canvas.GetTop(source); y_canvas = e

What's the easiest way to create a WPF progress bar without the dashed style?

£可爱£侵袭症+ 提交于 2019-12-07 21:54:28
问题 I'm looking to create a progress bar that doesn't use the WPF default style, which uses a dashed display. All I want is a simple, "smooth style" progress bar. In other words, I don't want to progress bar to be dashed. I want it to use a solid colored bar. What's the easiest way to do this? I assumed this would be part of the default API but I haven't been successful playing with it so far. Among other things, I've attempted to set the foreground brush, which only give me the color, not the

WPF Style for Control Library

瘦欲@ 提交于 2019-12-07 20:14:56
问题 I have a library ( Styles.DLL ) which contains a collection of keyed WPF Styles . I have a class library ( Module.DLL ) which contains a number of Windows and UserControls which can be shared across various applications. I use the keyed Styles defined in Styles.DLL to create implicit Styles for the various Controls used on these Windows and UserControls e.g. Button or ComboBox . I then have an application ( App.EXE ) in which I use the Windows defined in Module.DLL . I merge the required