wpf-controls

How to create a circle with a hole in a circle in WPF?

时光怂恿深爱的人放手 提交于 2019-12-18 15:53:45
问题 I have created a UserControl which is a ring by superposing 2 circles the small circle being blank and the second behind the smallest being colored. In my WPF app, I want to put several rings but the small circle does hide other rings. I'd like to see through it and also capture mouse event for ring behind other rings otherwise it's not real rings. Is it possible ? I tried OpacityMask for small ellipse as pointed by answer to http://social.msdn.microsoft.com/forums/en-US/wpf/thread/551201d1

Applying a WPF Style to multiple controls

[亡魂溺海] 提交于 2019-12-18 14:09:35
问题 This question is probably a duplicate, but I couldn't find it on SO. If I have a container Window , StackPanel , Grid , etc. is there any way I can apply a Style to all the controls of a certain type, that are contained within it? I can apply property changes, by using Container.Resources and setting individual changes to a TargetType , but when I tried setting the Style of the target, I get an error, telling me I can't set Style . Is there any way to do this in XAML? 回答1: Sort of, depending

Stop WPF ScrollViewer automatically scrolling to perceived content

此生再无相见时 提交于 2019-12-18 12:15:23
问题 The Application I am building an application which includes a range selector. This consists of two custom drawn Slider controls contained within one UserControl derived class. The range selector control is then contained inside a ScrollViewer which has the HorizonalScrollBar visible most of the time. Sample Application Code: ( appologies for the wall of text ) Window.xaml ( the Window file ): <Grid> <ScrollViewer x:Name="ScrollViewer" HorizontalScrollBarVisibility="Visible"

How to implement two-way binding on a property?

假如想象 提交于 2019-12-18 09:43:08
问题 I know there are lots of questions about dependency properties, and I have looked at many of them, but none of them seems to solve my problem. I have a Window like this: <Window x:Class="WpfBindingTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace

wpf customControl binding itemscontrol DataTemplate button

試著忘記壹切 提交于 2019-12-18 07:13:01
问题 i am new to WPF so i am stuck with some binding on my customcontrol click button. I have textbox that has watermark and selctedItems properties. Control if selecteditems != null display them in control as this: link to picture [http://s29.postimg.org/p25qgqzwn/image.jpg][1] Now i need to wire up X buttons to delete that item from selectedItems source. I am trying to do this in OnApplyTemplate method but i dont know how to get to that button in itemscontrol to attach mouse click event. my Xaml

Silent print HTML file in C# using WPF

不羁岁月 提交于 2019-12-18 06:50:56
问题 EDIT: Completely rewrote question and added bounty. Based on many tutorials and stackoverflow questions I can now: Print multiple pages together as one document. Print actual content. Align content correctly on page. Print correct size documents. The solution requires the HTML document to have some white space in the bottom and the style tag html{ overflow:hidden; } - to hide the scrollbars and to allow scrolling to be used for pagination - but I can accept this. The ONLY remaining problem is

WPF rotating button

杀马特。学长 韩版系。学妹 提交于 2019-12-18 06:11:53
问题 Help me plz. I need to animate rotation of the button on z-axis without using external libraries, only with C# and xaml code. Is that possible? How can I do that? Thanks. 回答1: Have a look at Viewport2DVisual3D The example in the link does exactly that. Edit: Here is the example from the link with an added animation of the Z axis Looks like this <Viewport3D> <Viewport3D.Camera> <PerspectiveCamera Position="0, 0, 4"/> </Viewport3D.Camera> <Viewport2DVisual3D x:Name="v2dv3d"> <Viewport2DVisual3D

How to suppress Cut, Copy and Paste Operations in TextBox in WPF?

廉价感情. 提交于 2019-12-18 06:07:08
问题 I want to suppress Cut, Copy and Paste operations in Text Box. I don't want user to do any of these operations through keyboard or from default context menu in the text box . Please let me know how can I restrict these operations? 回答1: You can do this pretty easily using the CommandManager.PreviewCanExecute routed event. In your XAML, you would put the following on your TextBox element. This will apply to CTL+V, etc as well as the context menu or any buttons that you may have mapped to those

How to suppress Cut, Copy and Paste Operations in TextBox in WPF?

耗尽温柔 提交于 2019-12-18 06:07:02
问题 I want to suppress Cut, Copy and Paste operations in Text Box. I don't want user to do any of these operations through keyboard or from default context menu in the text box . Please let me know how can I restrict these operations? 回答1: You can do this pretty easily using the CommandManager.PreviewCanExecute routed event. In your XAML, you would put the following on your TextBox element. This will apply to CTL+V, etc as well as the context menu or any buttons that you may have mapped to those

WPF Implicit selection of template using DataTemplate, but outside of 'List'

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 05:24:18
问题 In my project, I have TreeView, which contains a tree of objects of various types (all subclassed from the same superclass). To the right of my TreeView I would like to have a "panel" (at the moment I just have a Grid) which displays information about the object currently selected in the tree. I want to use DataTemplate, as in the second example on this page, to adapt the layout & content of my "panel" based on the subclass type; however, I cannot find a suitable container (as I don't want a