user-controls

What are the advantages/disadvantages of the different ways of binding content in a WPF UserControl to its properties?

最后都变了- 提交于 2019-12-31 02:20:15
问题 When starting to work with WPF UserControls, I stumbled upon several ways to bind content of a UserControl to one of its properties. Here's example C# code for my control: public sealed partial class MyUserControl : UserControl { public MyUserControl() { InitializeComponent(); } public static readonly DependencyProperty TheTextProperty = DependencyProperty.Register("TheText", typeof (string), typeof(MyUserControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.

Sizing issues while adding a .Net UserControl to a TabPage

放肆的年华 提交于 2019-12-30 18:42:37
问题 I have a complex Windows Forms GUI program that has a lot of automated control generation and manipulation. One thing that I need to be able to do is add a custom UserControl to a newly instatiated TabPage. However, when my code does this I get automatic resizing events that cause the formatting to get ugly. Without detailing all of the different Containers that could possibly be involved, the basic issue is this: At a certain point in the code I create a new tab page: TabPage tempTabPage =

How do I Access Buttons inside a UserControl from xaml?

泪湿孤枕 提交于 2019-12-30 17:22:35
问题 At work I have several pages, each with buttons in the same places, and with the same properties. Each page also has minor differences. To that end, we created a userControl Template and put all the buttons in it, then applied that user control to all the pages. However, now it's rather hard to access the buttons and modify them from each page's xaml, because they are inside a UserControl on the page..... How do I elegantly access the buttons from each page? What I've tried: Currently, we

How do I Access Buttons inside a UserControl from xaml?

别等时光非礼了梦想. 提交于 2019-12-30 17:22:32
问题 At work I have several pages, each with buttons in the same places, and with the same properties. Each page also has minor differences. To that end, we created a userControl Template and put all the buttons in it, then applied that user control to all the pages. However, now it's rather hard to access the buttons and modify them from each page's xaml, because they are inside a UserControl on the page..... How do I elegantly access the buttons from each page? What I've tried: Currently, we

Accessing WPF UserControl child element property

无人久伴 提交于 2019-12-30 15:42:24
问题 Let's say I have a UserControl with several child controls <UserControl x:Class="Any.AnyControl" <Grid> <Label Name="label1" Background="Black" /> ... more controls here </Grid> </UserControl> and I use it in MainWindow like so: <Window> <Grid> <local:AnyControl/> // I want to access AnyControl label1 Background property here </Grid> </Window> I know how I can access AnyControl label1 Background property in code-behind, but is there any way I can access it in parent XAML? my code now: in

Steps for embedding a windows forms user control in web page

霸气de小男生 提交于 2019-12-30 12:36:32
问题 I am developing a windows forms user control in Visual Studio 2005. It is a file upload control and uses only 2 elements. A button for showing opnefiledialog An openfiledialog I have added an object tag to the html page with the class id and all that. <OBJECT id="myControl1" name="myControl1" classid="ActiveXUploadFile.dll#ActiveXUploadFile.FileUpload" width=288 height=300></OBJECT> The namespace is ActiveXUploadFile and class name is FileUpload. But the control is not displayed in the web

How do I build a user control into a self-contained assembly in VS2008?

走远了吗. 提交于 2019-12-30 11:00:36
问题 More specifically, what do I need to know about doing this in Visual Studio 2008 that's different from VS2005? I have found a decent number of references for doing this kind of thing in VS2005, such as http://webproject.scottgu.com/CSharp/usercontrols/usercontrols.aspx Techniques For Distributing ASP.NET User Controls Across Projects http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx http://support.microsoft.com/kb/324785 but even the Microsoft reference doesn't seem to say much

Bindings on child dependency object of usercontrol not working

拈花ヽ惹草 提交于 2019-12-30 10:00:24
问题 I'm trying to get a binding to work on a child object of a user control. The Xaml looks like this: <MyGrid> <MyColumn ExtendedColumnData="{Binding ColumnToolTipDescriptions}"/> </MyGrid> Here is how the classes are defined: [ContentProperty("Columns")] public class MyGrid : UserControl { private MyColumnCollection _columns; [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Data")] public MyColumnCollection Columns { get { if (_columns == null) _columns = new

WPF UserControl Context Menu Visibility Binding

白昼怎懂夜的黑 提交于 2019-12-30 09:55:08
问题 My user control context menu visibility can't bind a dependency property. Any idea? Here is my WPF code <UserControl.ContextMenu> <ContextMenu Visibility="{Binding ElementName=wellControl, Path=IsInCompactMode, Converter={StaticResource BooleanToVisibilityConverter}}"> <MenuItem Command="local:GCommands.Edit" /> <MenuItem Command="local:GCommands.Delete" /> <MenuItem Command="local:GCommands.ExportFcsFiles" /> <MenuItem Command="local:GCommands.BatchExportStatistics" /> <Separator/> <MenuItem

How to stop WPF storyboard composed only in XAML

对着背影说爱祢 提交于 2019-12-30 09:24:11
问题 I have a animation defined in XAML (as a UserControl) that essentially switches between two images every second: <UserControl x:Class="KaleidoscopeApplication.Controls.RemoteAnimation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="RemoteAnimation_Loaded" Unloaded="RemoteAnimation_Unloaded"> <Grid Canvas.Left="500" Canvas.Top="84"> <Grid.Triggers> <EventTrigger RoutedEvent="Grid.Loaded"> <BeginStoryboard>