wpf-controls

How to traverse the item in the collection in a List or Observable collection?

主宰稳场 提交于 2019-12-25 03:42:56
问题 I have a collection that is binded to my Listview. I have provided options to user to "move up" "move down" the selected item in the list view. I have binded the selected item of the listview to my viewmodel, hence I get the item in the collection on which user want to do the operation. I have attached "move up" "move down" commands in my viewmodel. I want what is the best way to move up and down in the collection in the collection which is reflected in the list view. For example If the

how to dynamically change rectangle color in Expander?

Deadly 提交于 2019-12-25 03:26:18
问题 I have an Expander in which i have Rectangle with color. i want to change dynamically after some functionality. how to change it on run time ? <Windows.Resources> <ControlTemplate x:Key="SimpleExpanderButtonTemp" TargetType="{x:Type ToggleButton}"> <Border x:Name="ExpanderButtonBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" > <Grid> <Grid.ColumnDefinitions>

WPF grid cells in C# no text

故事扮演 提交于 2019-12-25 03:11:45
问题 I need to show some data in a structured way with colored letters and rows with background colors. I made a grid in a WPF Window. It shows the textboxes and some of the labels, but none of the text. Also the column header, last column, gridseperators, grid bot and left edges are invisible. My grid is called propertiesView. Code for adding header elements (labels) private void AddHeaderElement(string text, int row, int col) { Label headerElement = new Label(); headerElement.Height = cellHeight

StackPanel with huge amount of children

和自甴很熟 提交于 2019-12-25 02:46:12
问题 i'm building a wpf control based on the outlook calender sample in code project, first of all i wanna know if this is a good sample or that this is not the way of writing controls? second, i need to support milliseconds view of the calender, the meaning of that is more than 24 * 60 * 60 items my question is how to build this panel(if it should still be a StackPanel ) and how can i refill the panel when resolution (zoom) changes and avoid stucking the gui while i perform the fill. to sum up :

SelectedItem in TreeView

允我心安 提交于 2019-12-25 02:39:14
问题 I am trying to get the selected item from my TreeView but having some problem. I am following MVVM archetecture. My ViewModel contains a collection of a class which is in my Model. So I have binded the ItemSource of TreeView with that collection. I want to bind the selectedItem of my TreeView to an item of the binded collection. HOw do I do that. Here is the code for SelectedItem and IsSelected Property. private static sourceData _selectedItem = null; /// <summary> /// Selected Item in the

Why does the Combobox.FindName() method always return null?

纵然是瞬间 提交于 2019-12-25 02:39:10
问题 I have defined Combobox's ItemSource in List object. I want to reach the ComboBoxItem by using FindName() method but it always returns null. I have tried ApplyTemplate() at the beginning and I also have tried to reach the Item using Combobox.Template. Here is my code. Any suggestions? List<string> subjectsList = e.Result; cbCategory.ItemsSource = subjectsList; cbCategory.SelectedItem = cbCategory.FindName("DefaultChatSubject"); By the way, I do not have any problem about the Items in

How to correctly bind an object to a WPF DataGrid?

穿精又带淫゛_ 提交于 2019-12-25 01:46:35
问题 I'm trying to get a WPF DataGrid to work from a user control I'm building. Things seems to work fine. But I noticed this message in the Output window in the IDE: System.Windows.Data Error: 39 : BindingExpression path error: 'Name' property not found on 'object' ''Object' (HashCode=18165668)'. BindingExpression:Path=Name; DataItem='Object' (HashCode=18165668); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') System.Windows.Data Error: 39 : BindingExpression

Textblock dyanmic placement WPF

烂漫一生 提交于 2019-12-25 00:38:19
问题 I have a text data. I would like to place the data dynamically to a certain point [Absolute point, it may be (0,0) (10,10) or (100,100)]. Here the problem comes. My requirement is text block's center point should be the base point. How to make it and place it directly on the canvas? [Which means align the absolute point and center point of the textblock]. Because in winforms we can set the alignment property and place it directly. Please check this question .It describes how to move the

control margin properties depending on another control margin properties in wpf

你。 提交于 2019-12-24 19:02:42
问题 I'm trying to show two canvas control in a grid in my wpf applike this way. the second_canvas.margin.left will be the same as first_canvas.margin.right . but it can't be done since margin property can't be used as a variable. So I tried " Thickness ". but I can't convert first_canvas.margin.right to a thickness variable since it's a double type. So is there any work around for this? 回答1: You could write a dedicated value converter: using System; using System.Collections.Generic; using System

How to uncheck CheckBox on button click in WPF using C#?

ぐ巨炮叔叔 提交于 2019-12-24 19:01:01
问题 I have a CheckBox in GridControl Column. After performing some operation the selected checkboxes inside GridControl must be UNCHECKED on button click in WPF . Any idea? <dxg:GridControl Name="grdInfill" Height="700" VerticalAlignment="Center"> <dxg:GridControl.Columns> <dxg:GridColumn AllowEditing="True"> <dxg:GridColumn.CellTemplate> <DataTemplate> <CheckBox Name="chkSelect" HorizontalAlignment="Center" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=GlassType}"