user-controls

How can you access XAML-set properties of a UserControl during initialization?

你。 提交于 2020-01-22 12:42:45
问题 We're writing a custom UserControl (as opposed to a lookless control) and we need to perform some initialization based on what properties our consumers set on our control in XAML. Now in most cases, you'd use the Initialized event (or the OnInitialized override) since by the time that fires, all the XAML-set properties have been applied, but in the case of a UserControl, that isn't the case. When the Initialized event fires, all properties are still at their default values. I didn't notice

How can you access XAML-set properties of a UserControl during initialization?

北慕城南 提交于 2020-01-22 12:42:10
问题 We're writing a custom UserControl (as opposed to a lookless control) and we need to perform some initialization based on what properties our consumers set on our control in XAML. Now in most cases, you'd use the Initialized event (or the OnInitialized override) since by the time that fires, all the XAML-set properties have been applied, but in the case of a UserControl, that isn't the case. When the Initialized event fires, all properties are still at their default values. I didn't notice

Why does System.Windows.Controls.Button always have a padding of 10px?

最后都变了- 提交于 2020-01-21 12:20:53
问题 See screenshot. The bounding cyan-bordered box is the button, while the blue fill is the rectangle. I cannot for the life of me figure out how to get rid of the padding in the button. Is there a way to position the rectangle to the top left so it touches the cyan border? Thanks. 回答1: Did you try setting the Rectangle 's margin to 0 ? <Button x:Name="Button" BorderThickness="0" Margin="0" Padding="0" Width="96" Height="96"> <Rectangle Fill="Blue" Margin="0" Width="96" Height="96" /> </Button>

How to concat variable integer in control name in vb.net

隐身守侯 提交于 2020-01-21 10:25:20
问题 Now I have a database and pull out that data and display it to form,i have a sequence of groupbox and radiobuttons, in each groupbox (groupbox1,groupbox2,etc...) there are 2 radio buttons namely rdbtn1Yes and rdbtn1No (then it increment +1 in next Groupbox). now i use for loop to go through every groupboxes and radio buttons. And this is my code: Dim sqlda As New SqlDataAdapter("SELECT * FROM table1 WHERE column1= '" & lblWONo.Text & "'", Constr) Dim sqlds As New DataSet sqlds.Clear() sqlda

How to avoid visual artifacts of colored border of zoomable UserControl with rounded corners?

笑着哭i 提交于 2020-01-21 08:52:09
问题 I have a Form which contains: a TrackBar (minimum = 1, maximum = 200, represents zoom percent); a UserControl with BorderStyle = BorderStyle.None . Relevant code Form1 From designer code trackBar1.Value = 100; BackColor = Color.Gray; From code-behind private void trackBar1_Scroll(object sender, EventArgs e) { userControl11.SetZoomFactor(trackBar1.Value / 100F); } UserControl1 internal float MyBaseWidth; public UserControl1() { InitializeComponent(); MyBaseWidth = Width; SetZoomFactor(1); }

Dynamic user control change - WPF

夙愿已清 提交于 2020-01-21 05:21:12
问题 I'm developing an app in WPF and I need to change in runtime a content of a ContentControl depending than the user selected on ComboBox . I have two UserControls and at my combo exists two itens, corresponding each one each. First usercontrol: <UserControl x:Class="Validator.RespView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http:/

Dynamic user control change - WPF

帅比萌擦擦* 提交于 2020-01-21 05:21:07
问题 I'm developing an app in WPF and I need to change in runtime a content of a ContentControl depending than the user selected on ComboBox . I have two UserControls and at my combo exists two itens, corresponding each one each. First usercontrol: <UserControl x:Class="Validator.RespView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http:/

Force a custom WPF Control to resize correctly

China☆狼群 提交于 2020-01-20 03:34:53
问题 I have written a WPF user control and part of it involves dynamically adding elements to a canvas which effects the height of said canvas. The canvas is nested within a grid. When I dynamically add my elements the height of the canvas changes, but the canvas ends up extending beyond the edge of the overall control rather than causing the control to resize and make itself taller. How can I force the control to resize correctly? I get the feeling I need to either call or override Measure or

How to set DataSource property in.aspx file of a user control?

你。 提交于 2020-01-17 12:26:09
问题 I have a user control (don't want to create custom control) in this control i have a listbox. Now i want to user Datasource property which can be use as a datasource for this listbox. <UC:CustomList ID="list" CustomDataSource="objectDataSource1" runat="server" /> In control: public object CustomDataSource { get { return this.checkComboBox.DataSourceID; } set { this.checkComboBox.DataSource = value; } } It give runtime error "Cannot create an object of type 'System.Object' from its string

OnTextChange Partial Postback not occurring

北战南征 提交于 2020-01-17 07:54:37
问题 I have the following code for an OnTextChanged event: protected void CustomTextBox_OnTextChanged(object sender, EventArgs e) { if (tick.Attributes["class"] == "tick displayBlock") { tick.Attributes["class"] = "displayNone"; tick.Attributes.Add("class", "displayNone"); } checkAvailability.Attributes.Add("class", "displayBlock"); checkAvailability.Attributes["class"] = "displayBlock"; } And: <asp:UpdatePanel ID="upMyUpdatePanel" runat="server"> <ContentTemplate> <uc:CustomTextBox ID=