user-controls

Is it possible to load a UserControl into an anonymous object, instead of just instantiating it?

笑着哭i 提交于 2019-12-24 23:31:11
问题 Currently I'm generating UserControls as follows in an abstract base class so they are available for any other pages that implement the base class: // doc is an XML file that may or may not contain a TopStrapline node var pageControls = new { TopStrapline = (from strap in doc.Elements("TopStrapline") select new TopStrapline { StraplineText = (string)strap.Attribute("text") }).FirstOrDefault(), // loads of other UserControls generated from other nodes }; // if there's a StrapLine node, I want

UserControl DataContext Binding

自作多情 提交于 2019-12-24 23:06:08
问题 I have three projects in my solution: My main WPF Application which contains a MainWindow + MainViewModel UserControl Library with a UserControl ( ConfigEditorView ) UIProcess class with the ViewModel for the UserControl ( ConfigEditorViewModel ) In my MainWindow I want to use the UserControl with the ViewModel of UIProcess. First I set the UserControl in my MainWindow : <TabItem Header="Editor"> <Grid> <cel:ConfigEditorView DataContext="{Binding ConfEditModel, NotifyOnSourceUpdated=True,

Why do I get a XamlParseException when I inherit a Custom UserControl in another project?

做~自己de王妃 提交于 2019-12-24 22:46:27
问题 In one project I have an Editor Class: namespace TestXamlInherit234 { public class CustomerEditor : BaseEditor { public CustomerEditor() { TheMessage.Text = "changed222"; } } } which inherits from a WPF User Control in another project : using System.Windows.Controls; namespace Core { public partial class BaseEditor : UserControl { public TextBlock TheMessage { get { return TheMessage2; } } public BaseEditor() { InitializeComponent(); } } } <UserControl x:Class="Core.BaseEditor" xmlns="http:/

For Each DataTable Add UserControl to FlowLayoutPanel

天涯浪子 提交于 2019-12-24 20:18:14
问题 I have created a UserControl which has a picture and two labels: labelName labelUsername I have also created a DataSet and DataTable which gets the data from a SQL CE database. This bit is working fine as I managed to loop through all the DataTable rows and display the information in a MessageBox. Now I want to display the UserControl in a FlowLayoutPanel for all rows in the DataTable and populate the two labels with the Name and Username values from the DataTable. This is where I am stuck as

Animate UserControl in WPF?

北慕城南 提交于 2019-12-24 19:43:26
问题 I have two xaml file one is MainWindow.xaml and other is userControl EditTaskView.xaml . In MainWindow.xaml it consists of listbox and when double clicked any item of listbox, it displays other window (edit window) from EditView userControl. I am trying to animate this userControl everytime whenever any item from the listbox is double clicked. I added some animation in userControl however the animation only gets run once. How can i make my animation run everytime whenever any item from the

MouseEnter event in Winform ElementHost

自作多情 提交于 2019-12-24 19:19:51
问题 I have a Winform with an elementHost in it to contain a WPF UserControl. What I need, is to do something when the mouse enters the elementHost, not the child. I was trying to use MouseEnter event in the elementHost but it does not exists. Is there any chance I can do this? Or is it just not possible? It´s curious to not have mouse events on them. This are all the events I have: And if I want to do it programatically I just dont have any MouseEvent: 回答1: MouseEnter event located in

Adding ComboBoxItem to a combobox inside a user control (XAML/WPF)

ぃ、小莉子 提交于 2019-12-24 19:11:28
问题 I am currently learning to create custom controls in WPF. I successfully created a simple custom control using a Label and a Text Box. I was able to allow setting the Label text by DependencyProperty. Now I am creating a user control that has a ComboBox. I need to allow adding items to this ComboBox from outside the control. To achieve this, I tried exposing a DependencyProperty of type ItemsCollection and it will allows access to the ComboBox's Items property (the DP in my control sample is

Transparent User Control in .net

余生长醉 提交于 2019-12-24 18:33:15
问题 I'm trying to make a web style button with user control. I need to make User Control's background transparent. How to do this without making controls invisible. Also I'll need transparent Label and PictureBox. Trying to make something like this: this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; 回答1: All three controls you list already have the ControlStyles.SupportsTransparentBackColor style turned on. Just set the BackColor property in the

Implement Dispose(bool) on a UserControl

痞子三分冷 提交于 2019-12-24 18:16:29
问题 How to implement the Dispose(boolean) at a UserControl... when the VS Designer already implemented it with a DebuggerNonUserCode attribute? Will my modifications on this method removed? (code from UserControl.Designer.vb) <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) 回答1: You need to remove the Dispose method from the designer file and add it to your source file. You should probably also remove the DebuggerNonUserCode attribute. At

Register ViewState for “visible=false” UserControl - ASP.NET

ε祈祈猫儿з 提交于 2019-12-24 18:10:59
问题 We have a web app(-ish) webform, and we use many custom UserControl s. We load a bunch of them in each view, but we don't want them to render, or even pre-render, until we don't have to use them. Then we set Visible = False in each control and then we use Update Panel s to set it to True whenever the control is needed. The control then shows up correctly. But in the next postback we have a very nasty MAC validation error, and we think it is related to the ASP not updating the viewstate (but I