wpf-controls

Submission of a webpage form using WebBrowser control in C#

天涯浪子 提交于 2020-01-01 09:58:29
问题 I have seen a lot of posts regarding this particular subject on SO as well as on the web in general and most if not all code is as seen below private void btnSubmit_Click(object sender, RoutedEventArgs e) { webBrowser1.Navigate(new Uri("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onsubmit.htm")); } private void btnLogin_Click(object sender, RoutedEventArgs e) { mshtml.HTMLDocument htmlDoc = null; htmlDoc = (mshtml.HTMLDocument) this.webBrowser1.Document; if

Checking if a RoutedEvent has any handlers

本小妞迷上赌 提交于 2020-01-01 06:27:56
问题 I've got a custom Button class, that always performs the same action when it gets clicked (opening a specific window). I'm adding a Click event that can be assigned in the button's XAML, like a regular button. When it gets clicked, I want to execute the Click event handler if one has been assigned, otherwise I want to execute the default action. The problem is that there's apparently no way to check if any handlers have been added to an event. I thought a null check on the event would do it:

Checking if a RoutedEvent has any handlers

我的未来我决定 提交于 2020-01-01 06:27:17
问题 I've got a custom Button class, that always performs the same action when it gets clicked (opening a specific window). I'm adding a Click event that can be assigned in the button's XAML, like a regular button. When it gets clicked, I want to execute the Click event handler if one has been assigned, otherwise I want to execute the default action. The problem is that there's apparently no way to check if any handlers have been added to an event. I thought a null check on the event would do it:

Include a Button in a TextBox

不想你离开。 提交于 2020-01-01 03:19:08
问题 I want to add a little Button , which removes all the text in the TextBox . Is it possible to put this "Remove"-Button into the TextBox (like in the iPhone Textboxs )? I hope after your help it looks like that: I played something with the controltemplate but didn't get the wished result. One way to solve this problem could be to use negative margins of the button, but i think that isn't a clean solution. Thank you! 回答1: You can easily derive from textbox and create your own textbox with the

Programmatically add label to grid

故事扮演 提交于 2020-01-01 02:26:08
问题 Hey all i am trying to add a label to my grid using the following code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click Dim dynamicLabel As New Label() Dim g As New Grid dynamicLabel.Name = "NewLabel" dynamicLabel.Content = "TEST" dynamicLabel.Width = 240 dynamicLabel.Height = 30 dynamicLabel.Margin = New Thickness(0, 21, 0, 0) dynamicLabel.Foreground = New SolidColorBrush(Colors.White) dynamicLabel.Background = New

'Graying Out' a WPF button image?

五迷三道 提交于 2019-12-31 08:34:06
问题 I have a simple Button control that contains an Image object as its content. I want so set the Image opacity to 0.5 when the Button is disabled to provide an additional visual cue as to the Button status. What is the simplest way to accomplish that result in XAML? Thanks for your help. 回答1: Use a trigger in the Image style. (It would be more natural to put it in the Button style, but the Button style can't easily affect the Image for annoying technical reasons. It could be done in the Button

Why is a Line shape on a Canvas drifting away while dragging?

做~自己de王妃 提交于 2019-12-31 05:03:21
问题 I see a strange behaviour dragging in Line shape over a Canvas that I cannot explain. The Line shape is in a Thumb DataTemplate like so: <DataTemplate DataType="{x:Type vm:MyLine}"> <Thumb DragDelta="Thumb_DragDelta"> <Thumb.Template> <ControlTemplate TargetType="Thumb"> <Line Fill="LightBlue" StrokeThickness="2" Y1="{Binding Y1}" Y2="{Binding Y2}" X1="{Binding X1}" X2="{Binding X2}" Stroke="LightBlue" x:Name="Line"/> </ControlTemplate> </Thumb.Template> </Thumb> </DataTemplate> The Canvas is

Binding a resource to a custom control property

眉间皱痕 提交于 2019-12-31 03:18:52
问题 I am creating a custom button that shows slightly faded text normally, and full-strength text on a MouseOver or MouseDown . I have defined two resources in the Generic.xaml of my control to represent the brushes for these text colors: <!-- Text Brushes --> <SolidColorBrush x:Key="NormalTextBrush" Color="Black" /> <SolidColorBrush x:Key="FadedTextBrush" Color="Gray" /> The control compiles and works fine in that configuration. But I want to let the control user set the text color, using the

Using MouseDragElementBehavior with an ItemsControl and Canvas

对着背影说爱祢 提交于 2019-12-31 02:52:06
问题 I am currently having a problem using the MouseDragElementsBehavior from the Blend SDK when using a ItemsControl and a Custom Canvas. My custom canvas simply adds or removes the MouseDragElement from its children depending on a DependencyProperty. This worked just fine when I was manually adding Items to the Canvas' children but appears to have broken when moving to an ItemsControl. I am currently using the following ItemsControl code: <ItemsControl ItemsSource="{Binding Path=CanvasItems}">

Why is this multibinding not working

我怕爱的太早我们不能终老 提交于 2019-12-30 18:28:18
问题 I have sending multiple parameters from my Checkbox Command. I have used a converter. The code is below. If i put a debugger and see the values here are my results : When checkbox check is either checked or unchekcked : In the converter it has teh values (Array of the item object and boolean). But when i come to my method, the value is a object[2] but both values are NULL CheckBox XAML <CheckBox x:Name="checkBox" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content