wpf-controls

Saving the Image from WPF control to SQL Server DB

房东的猫 提交于 2020-01-06 12:42:08
问题 I have an application written in WPF 3.5 which at some point it saves the data in including an image in SQL Server, this is part of the code in saving the data (note this.pictureImage is a WPF Image control):- using (SqlCommand command = myConnection.CreateCommand()) { String sqlInsertCommand = "INSERT INTO Info_Id (idNumber, FirstName, Nationality, Image) VALUES (@idNumber, @firstName, @nationality, @image)"; command.CommandText = sqlInsertCommand; command.CommandType = System.Data

Is there a way to automatically expose properties and events of a standard wpf control wrapped in a user control?

夙愿已清 提交于 2020-01-06 12:14:29
问题 I wrapped a standard control as discussed here Quickest way to inherit a standard control in WPF? in a user control. Now is there a way to automatically expose properties and events of a standard wpf control wrapped in a user control ? Could I use something like automatic Bubbling routing but how exactly ? Otherwise I'll have to also create properties and events wrappers for my component that is cumbersome. 回答1: Yes, you have to provide new Dependency Properties on the user control to expose

How to write ListViewItem that contain image , text and button?

一笑奈何 提交于 2020-01-06 05:23:15
问题 I need to write some listViewItem ( using WPF ) - that contain image, text and button. I want to inherit from the simple listViewItem class and add to the listview item that contain the three items ( image, text, button ). I don't understand how the listView control will arrange the 3 items ( image , text, button ) in the right order in the control - how to tell the listview control that the image is first, text is second and the button is the third ? 回答1: First read more about Layout

How to find Mouse movement direction?

試著忘記壹切 提交于 2020-01-05 23:18:11
问题 I need to find out the direction (Left or RIGHT) of a mouse from the moment the mouse is being pressed. I can use only the event OnMouseMove. Using the following method I cannot get the direction as e.GetPosition(this).X it is the same value when the mouse move and when it is clicked. Any idea how to solve it? protected override void OnMouseMove(MouseEventArgs e) { currentPositionX = e.GetPosition(this).X; if (e.LeftButton == MouseButtonState.Pressed) { double deltaDirection =

How to find Mouse movement direction?

馋奶兔 提交于 2020-01-05 23:17:02
问题 I need to find out the direction (Left or RIGHT) of a mouse from the moment the mouse is being pressed. I can use only the event OnMouseMove. Using the following method I cannot get the direction as e.GetPosition(this).X it is the same value when the mouse move and when it is clicked. Any idea how to solve it? protected override void OnMouseMove(MouseEventArgs e) { currentPositionX = e.GetPosition(this).X; if (e.LeftButton == MouseButtonState.Pressed) { double deltaDirection =

WPF Performance Problems with derived TextBox controls

坚强是说给别人听的谎言 提交于 2020-01-05 21:28:23
问题 I have a WPF application that renders input forms based on form-configurations saved in a database. The forms have many controls (100+) and most of these controls are derived from a TextBox-control. On some machines (fast Hardware, Win7 32Bit, also some elder, Windows XP 32Bit), after entering data to a lot of these forms, input performance goes down. Every keystroke gets a delay of some milliseconds and the only solution to resolve this is to close the application and restart it. My derived

WPF Performance Problems with derived TextBox controls

假如想象 提交于 2020-01-05 21:23:30
问题 I have a WPF application that renders input forms based on form-configurations saved in a database. The forms have many controls (100+) and most of these controls are derived from a TextBox-control. On some machines (fast Hardware, Win7 32Bit, also some elder, Windows XP 32Bit), after entering data to a lot of these forms, input performance goes down. Every keystroke gets a delay of some milliseconds and the only solution to resolve this is to close the application and restart it. My derived

Find children of a user control, in a tab item

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 08:08:31
问题 I have an issue related to finding children of a user control. The user control resides in a tab item of a tab control XAML <TabControl HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="150"> <TabItem Header="First tab"> <Grid Background="#FFE5E5E5"/> </TabItem> <TabItem Header="Tab with stackpanel" x:Name="tabWithStackPanel"> <StackPanel> <TextBox></TextBox> <TextBox></TextBox> <TextBox></TextBox> <TextBox></TextBox> <TextBox></TextBox> <TextBox></TextBox> <TextBox><

Listview to display ObservableSelection

蹲街弑〆低调 提交于 2020-01-05 05:55:33
问题 I have Student table, Course table and a StudentCourse table. On my WPF, I'm making "Student" selections with combo box. How can I display the corresponding Course and its properties(CourseID, CourseName, Credit) in a listview, using ObservableCollection?. Here's my code for the combo box SelectionChanged event private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { int MySelect = (int)this.comboBox1.SelectedValue; var SelectedStudent = db.Students.Include(

WPF Loose XAML ResourceDictionary

与世无争的帅哥 提交于 2020-01-04 07:49:10
问题 I am trying to use a ResourceDictionary in loose XAML and load it a runtime to provide templates and styles to a WPF app. I have the XAML available in a local directory and am adding a new ResourceDictionary to App.Current.Resources.MergedDictionaries in app startup using a URI. When the XAML goes to parse, it blows up on a template where the TargetType is a custom control from the assembly that is consuming it. The specific message is: 'Failed to create a 'Type' from the text 'controls