wpf-controls

How to know what control the mouse has clicked in a canvas?

别说谁变了你拦得住时间么 提交于 2019-12-25 16:02:30
问题 I am creating a C# WPF application and looking for a way to do the following: I have a canvas with different user controls in it and a button. When I click on the button the cursor change to a hand (Canvas.Cursor = Cursors.Hand) Then if I click on one of the controls I get a message box showing the name of the control clicked (the name is a public property of the control). If I click somewhere else i the cursor resets and I should click on the button again before I can get the name again. I

How to know what control the mouse has clicked in a canvas?

落花浮王杯 提交于 2019-12-25 16:01:45
问题 I am creating a C# WPF application and looking for a way to do the following: I have a canvas with different user controls in it and a button. When I click on the button the cursor change to a hand (Canvas.Cursor = Cursors.Hand) Then if I click on one of the controls I get a message box showing the name of the control clicked (the name is a public property of the control). If I click somewhere else i the cursor resets and I should click on the button again before I can get the name again. I

how to get the correct index in a datGrid when I use the MVVM pattern and I have a filter in the dataGrid?

泪湿孤枕 提交于 2019-12-25 10:58:07
问题 I have a DataGrid in my view, and I would like to select a row. In my view model I have a property to bind the SelectedIndex of the dataGrid. When I add a new row to the dataGrid, this element is add at the end of the elements, show in the dataGrid I can see it in the last position. However, if i have shorted the elements in the dataGrid because I click in a column name and this filter makes that the new element it will be in the first position of the dataGrid, then I select the incorrect

Saving XAML custom control as a jpg/png file

心不动则不痛 提交于 2019-12-25 09:40:33
问题 I have some objects at wpf window and I want to save one of them into a .png / jpg file. It is posible using wpf ? how to do it ? UPDATE The object is a customControl, something like Printdialog.Printvisual but jus to save my control UI as an image file Here is my XAML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:OdontogramaUI="clr-namespace:Gramas.OdontogramaUI;assembly=Gramas" x:Class="Salud.Views

Displaying one element in combobox from comboboxitems

五迷三道 提交于 2019-12-25 09:04:20
问题 I'm sorry the title is badly worded and change it if you must, but this is what I am trying to achieve. I have styled a combobox and added some items: When an item is selected I wish only the title to be displayed, at the moment the whole content is displayed: I have been playing around with using Tags to define the textblock with text "Title" as a header and display that however it's not working :(. Here is the XAML Styling within app.xaml, I haven’t placed in a resource dictionary yet as I

Trying to update control and getting NullReferenceException

Deadly 提交于 2019-12-25 08:23:02
问题 i got answer to my last problem related to my mini project: when i tried to update image control from other thread i got error: Trying to update image control source from other tread and getting Error- enter link description here but now i got NullReferenceException at this line: item.Dispatcher.Invoke(new Action(() => image1.Source = item)); from some reason and i dont know why? the code: public partial class MainWindow : Window { BlockingCollection<BitmapSource> pictures = new

How to modify the default control themes?

给你一囗甜甜゛ 提交于 2019-12-25 08:14:00
问题 I want to modify the default control templates for my project. For my first change, I just want to establish a part name for the listview's ScrollViewer in each theme. Here is my structure: MyControlLibrary: defines a couple controls and defines the themes for the standard wpf controls. MyApplication: uses the control library and included themes. Here is what I have figured out so far. Download the default themes from: http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx

Image inside sliding CheckBox in XAML

心已入冬 提交于 2019-12-25 04:47:15
问题 I have the following style that I got from [Here]https://stackoverflow.com/a/5349484/3260977) and I have added an image to the Border with x:Name = "slider". I want to reuse this control and want to be able to assign the image source for each control without having to duplicate the style for each control. Here is my style: <Style x:Key="OrangeSwitchStyle" TargetType="{x:Type CheckBox}"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />

Trigger to set wpf textbox borderbrush not working

我只是一个虾纸丫 提交于 2019-12-25 04:45:32
问题 Im trying to set the background borderbrush on a simple textbox when the textbox has focus. This is my style <Style x:Key="TextBoxStyle" TargetType="TextBox"> <Style.Triggers> <Trigger Property="IsFocused" Value="False"> <Setter Property="BorderBrush" Value="Blue"/> </Trigger> <Trigger Property="IsFocused" Value="True"> <Setter Property="BorderBrush" Value="Red"/> <!--<Setter Property="Background" Value="Red"/>--> </Trigger> IsFocus = False works correctly however the trigger for true doesnt.

Check time after a mousebuttondown before the mousebuttonup

狂风中的少年 提交于 2019-12-25 04:31:54
问题 I think that must be only a little problem, but I can't get a clear thought on that. Someone an idea? I have some borders on a canvas (filled with images) and i want to click the border (i do this with the OnMouseLeftButtonDown) where the border gets red (so the user knows for sure which object he had clicked) and then, after 1 or 2 seconds, when the mousebutton is still pushed down, a drag'n'drop should start. At first I had the borders inside buttons, but the clickevent seems to conflict