wpf-controls

Make a window draggable within a certain boundary WPF

∥☆過路亽.° 提交于 2020-01-04 02:26:29
问题 I have a wpf child window that I allow dragging by using the DragMove() method. However, I need to allow the window to be dragged only within the bounds of its Parent window control. Can anyone suggest a way to achieve this? Thanks! 回答1: There are two ways to do this. Using LocationEnded If you handle this event you can change the Top or Left to be within the bounds of the owner window. e.g. private void Window_LocationChanged(object sender, EventArgs e) { if (this.Left < this.Owner.Left)

WPF Underline a letter in a label element

隐身守侯 提交于 2020-01-03 21:32:57
问题 I have a label next to a text box which has a short cut key. The XAML for the label looks like: <Label>Enter your _Name</Label> Where if you press alt+N it sets focus in the textbox where you would enter your name. I'd like the letter N to be underlined so that when the user sees the label it looks like: Enter your N ame (well N is bold here, but I'd like it be underlined :)) Thanks for your help! 回答1: The N will automatically be underlined when the Alt key is pressed. You'll see this

WPF Underline a letter in a label element

◇◆丶佛笑我妖孽 提交于 2020-01-03 21:31:09
问题 I have a label next to a text box which has a short cut key. The XAML for the label looks like: <Label>Enter your _Name</Label> Where if you press alt+N it sets focus in the textbox where you would enter your name. I'd like the letter N to be underlined so that when the user sees the label it looks like: Enter your N ame (well N is bold here, but I'd like it be underlined :)) Thanks for your help! 回答1: The N will automatically be underlined when the Alt key is pressed. You'll see this

WPF Datepicker making only a list of dates selectable

扶醉桌前 提交于 2020-01-03 18:35:28
问题 I'm not sure if this is possible but is it possible to make only a list of dates selectable in a wpf datepicker? I need to make sure that the use can only select from a certain amount of dates. I can do this with a dropdownlist, but with a datepicker it would be much nicer. Any ideas? 回答1: The DatePicker has the following properties to control which dates should be selectable: DisplayDateStart : The first date to include in the Calendar popup. DisplayDateEnd : The last date to include in the

How to highlight the border lines of a Grid control

房东的猫 提交于 2020-01-03 13:39:11
问题 I have wrote some code in order to add 100 x 100 cells to a grid. The thing is that I would like to highlight the lines that split the rows/column of the grid. What properties should I use, or how should I do that? Bellow is the code for creating the grid cells : public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); for (int i = 0; i < 100 ; i++) layoutGrid.RowDefinitions.Add( new RowDefinition { } ); for (int i = 0; i < 100; i++) layoutGrid.ColumnDefinitions

How to highlight the border lines of a Grid control

蓝咒 提交于 2020-01-03 13:39:03
问题 I have wrote some code in order to add 100 x 100 cells to a grid. The thing is that I would like to highlight the lines that split the rows/column of the grid. What properties should I use, or how should I do that? Bellow is the code for creating the grid cells : public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); for (int i = 0; i < 100 ; i++) layoutGrid.RowDefinitions.Add( new RowDefinition { } ); for (int i = 0; i < 100; i++) layoutGrid.ColumnDefinitions

WPF ListView non integral scrolling

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 10:41:53
问题 How do I turn off the integral scrolling in a WPF ListView? By default, scrolling a ListView jumps down so I must scroll a whole item at a time. I would like to scroll half way, quarter way, etc. 回答1: Set the property ScrollViewer.CanContentScroll of your ListView to False. Then the contents will scroll pixel-wise. 来源: https://stackoverflow.com/questions/3840959/wpf-listview-non-integral-scrolling

WPF drag and drop files onto TreeView from windows explorer

筅森魡賤 提交于 2020-01-03 09:46:25
问题 I am trying to make an extremely simple, or so I thought, program to drag and drop a file from the desktop/explorer onto a wpf treeview. The treeview in this example is simple so that I could isolate the drag and drop problem I am having. I have set AllowDrop equals True all over the place, I still can't get the Drop or DragOver events to fire. I am focused on a treeview control because I want to be able to drag files into different nodes with a hierarchical structure. Right now I would

wrapping content in a StackPanel wpf

偶尔善良 提交于 2020-01-03 06:49:10
问题 is it possible to wrap content in a StackPanel ? I know that we can make use of a WrapPanel instead. But for code modifying reasons, I must make use of a StackPanel . So, is there a way to make the items in a StackPanel wrap after say 5 items... Thanks! 回答1: Create nested StackPanel s which contain the required number of items. In the example below, you have two rows, respectively occupied by the <StackPanel Orientation="Horizontal"> elements, which in turn each contain five items that will

How to enforce distinct selections when multiple ComboBox's are bound to a common source?

一笑奈何 提交于 2020-01-03 05:24:08
问题 In my WPF app i have 4 comboboxes. They all are populated this way; combobox1.ItemSource = dt.DefaultView; combobox1.DisplayMemberpath = "Name"; combobox2.ItemSource = dt.DefaultView; combobox2.DisplayMemberpath = "Name"; and so on for combobox3 and combobox4 . This dt (DataTable) already contains distinct Names as I am fetching records using distinct Name . Now what should I do so that when a Name is selected from combobox1 it should not be available in other 3 comboboxes list. I read a