wpf-controls

Looping through controls in WPF / Powershell

此生再无相见时 提交于 2019-12-12 01:28:29
问题 I am trying to loop through some controls in a Powershell / WPF application. Nothing fancy, just setting some text on a mouseEnter event. It works fine if I don't loop the code: $reader = New-Object System.Xml.XmlNodeReader $xaml $d = [Windows.Markup.XamlReader]::Load($reader) $d.FindName("GridOne").add_mouseEnter({ $d.FindName("HelpText").Content = "One" }) $d.FindName("GridTwo").add_mouseEnter({ $d.FindName("HelpText").Content = "Two" }) $d.FindName("GridThree").add_mouseEnter({ $d.FindName

How to instantiate a Datagridview(in code behind)

帅比萌擦擦* 提交于 2019-12-12 00:27:25
问题 I am actually using a datagrid which is filled by a datatable to display my data(NOTE: These are dynamic data). Till now I was proceeding as below grid = new Microsoft.Windows.Controls.DataGrid(); My datatable as table = new System.Data.DataTable(); and I fill the datagrid with the datatable by doing grid.ItemsSource = table.DefaultView; However Due to dificulties I am facing to delete a column etc of the datagrid,I want to move to Datagridview instead of the datagrid. I tried grid = new

Current value displayed in ComboBox

℡╲_俬逩灬. 提交于 2019-12-12 00:15:49
问题 I can't seem to get the current selected value to show in the ComboBox when the items in the ComboBox are custom objects from the database. I put together the following test ViewModel and View. SimpleWidgets and ObjectWidgets behave as expected. CodeWidgets (list retrieved from the database as custom 'Code' objects) never displays the SelectedCodeWidget. public class TestViewModel:BaseTabViewModel { private List<int> simpleWidgets; public List<int> SimpleWidgets { get { return simpleWidgets;

Removing UserControl code behind for use with MVVM

谁说我不能喝 提交于 2019-12-11 23:23:00
问题 I am trying to create a user control using MVVM. Basically I am trying to wrap a combobox that will pull data from a respository. This will allow me to use the same combobox in many different views in my application. There will be many of the wrapped comboboxes throughout the application. I was easily able to create this control using a DependencyProperty and code-behind. I am now trying to convert this to MVVM and am having trouble figuring out how to get the value back to /from the

How to paint notebook-like lines as TextBox background?

南笙酒味 提交于 2019-12-11 22:14:52
问题 A bit similar to this question. My aim is to evocate a notebook-like look of the textbox. OneNote does something similar, by setting background image of the editing surface. Of course it is not possible to align the lines in OneNote because the text can be freely formatted. I would like to do this with constant font (no formatting) in WPF. How to paint lines in textbox background that will match the lines of text? 回答1: I asked the same question here: Repeat a background brush in WPF It would

Multibinding WPF

*爱你&永不变心* 提交于 2019-12-11 21:01:02
问题 I am arranging few textblocks in a canvas based on it's locations. sample code snippet is provided below at bottom. For this process I need to access each textblock's Actualwidth and Actual Height inside ItemContainerStyle. I am struggling to access it's properties as below by element name, because it doesn't have a name. How to do it? Do I need to do through templates? <MultiBinding Converter="{StaticResource BPositionConverter}" ConverterParameter="Left"> <Binding ElementName="TextBlock"

WPF WebBrowser Control Custom Property

故事扮演 提交于 2019-12-11 20:27:29
问题 Ok. So I ran across a couple code examples stating that I can create a custom property for the WPF WebBrowser control, that will allow me to bind a string of html to the control for rendering. Here is the class for the property (which is in a file called BrowserHtmlBinding.vb): Public Class BrowserHtmlBinding Private Sub New() End Sub Public Shared BindableSourceProperty As DependencyProperty = DependencyProperty.RegisterAttached("Html", GetType(String), GetType(WebBrowser), New

Binding DependencyProperty to non-DependencyProperty

烈酒焚心 提交于 2019-12-11 20:05:25
问题 I have a usercontrol from winforms. In the XAML I am trying to bind a dependency property to one of the usercontrol's property as below (which is not a dependency property) <Pricing:UserControl1 UserControlProperty="{Binding CurrentProductItem.ComponentId}" /> I am getting an error A 'Binding' cannot be set on the 'UserControlProperty' property of type 'UserControl1'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject. How I can solve this issue? Do I need to make

get all selected items from wpf checkbox list give me error

落爺英雄遲暮 提交于 2019-12-11 19:54:51
问题 I have ListBox with checked box as following, and it binding its data from SQL server database . I want to get selected items value When I run this but I got this error: Unable to cast object of type 'System.Data.DataRowView' to type 'System.Windows.Controls.CheckBox'. This is code: <Window.Resources> <DataTemplate x:Key="NameColumnTemplate"> <CheckBox Height="20" FontFamily="Arial" FontSize="14" Content="{Binding Path=PermissionDescription}" Tag="{Binding PermissionID}" HorizontalAlignment=

Create a usercontrol with overlapping content

僤鯓⒐⒋嵵緔 提交于 2019-12-11 19:27:58
问题 I need to make a (user/custom) control which when 'folded open' displays content over other controls. Like a popup, combo or menu except that the content will still open (think toggle button style). Any leads? 回答1: Depends on many issues. I know at least two ways to achive it. First - using <Popup /> . Its easy to bind its IsOpen property to bool variable. And if you need to close it, I have got some smart behavior (which close popup when Esc key is pressed or when it lost focus). The second