w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Only the last usercontrol shows contentcontrol
Set x:Shared=false on resource. It will work. <Canvas x:Key="appbar_close" x:Name="appbar_close" x:Shared="false" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0" >

Categories : C#

What's the difference betwen a UserControl and a ContentControl?
Basically, the UserControl class is there for convenience. It enables us to build little parts of the UI from already existing controls, whereas ContentControls are really for creating new controls, generally with a single purpose and/or functionality. I read a book that had a good explanation of this and by good luck, someone has 'put a copy of it online'. From the linked book: The UserControl class is a container class that acts as a “black box” container for a collection of related controls. If you need a set of three controls to always appear together and be allowed to easily talk to each other, then a likely candidate for making that happen is the UserControl class. Then relating to whether to create a CustomControl: The following is a summary of the decision proc

Categories : Wpf

Display loading animation in contentcontrol while bound usercontrol is loading
Do your data access stuff in a Background Thread. Then put some IsBusy property in the ViewModel and show some "Loading Message" when that becomes true: public void DoHeavyStuff() { IsBusy = true; Task.Factory.StartNew(() => GetDataFromDB()) .ContinueWith(x => IsBusy = false); } Remove all heavy operations from constructors. That's a bad design.

Categories : Dotnet

Acess UserControl inside another UserControl
You should not access controls like that, unless you have no other choice. In your case, iF you what to expose selected DateTime in your first user control, then simply declare a Dependency Property which will hold and update this value (via DataBinding or event).

Categories : C#

How do we change styles in a word contentcontrol via VB.Net
Converting your code to VBA (second part where you add 'essais' text) I would have this one: With CC.Range.Characters.Last .InsertParagraphAfter .Move wdParagraph '!!!!!!!!! .Style = "Nagłówek 1" .Text = "essais" End With As you can see I've added one line with '!!!! comment moving insertion point to next paragraph which was add with .InsertParagraphAfter method.

Categories : Vb.Net

Change content of contentcontrol on mouse over (Freezable cannot be frozen)
From the Freezable Objects Overview page at MSDN: A Freezable can't be frozen if any of the following are true: • It has animated or data bound properties. • It has properties set by a dynamic resource. (See the Resources Overview for more information about dynamic resources.) • It contains Freezable sub-objects that can't be frozen. I'm guessing that it applies to your Canvas control because you have a Path object inside it that itself can't be frozen because of the DynaimcResource it uses.

Categories : C#

Use LoadControl to programmatically load WebControl (not UserControl)
Just enstantiate your custom control and add it to the Controls collection. LoadControl is for UserControls. var listItemHyperLink = new ListItemHyperLink(); listItemHyperLink.Text = "Google"; listItemHyperLink.NavigateUrl = "http://google.com/"; listItemHyperLink.ListItemCssClass = "li-class"; listItemHyperLink.CssClass = "a-class"; UnorderedList.Controls.Add(listItemHyperLink);

Categories : C#

javascript inside Usercontrol inside updatepanel is undefined
problem solved with the following script, that i put outside the update panel : function pageLoad() { $(".datepicker").datepicker({ changeMonth: true, changeYear: true, minDate: "-100Y", maxDate: "-15Y", dateFormat: "dd/mm/yy", yearRange: "1913:2300" }); //more Code executed on each postback from the update panel ... }

Categories : Asp Net

Using a Usercontrol inside Datatemplate
I have answered the similar one yesterday. Please check if it helps. how to add user controls as listbox items Thanks

Categories : C#

UserControl inside DataList
Difficult to answer without looking at the whole page lifecycle, but you may try to store the MessageId in your control's ViewState, like this : Public Property MessageID As Integer Get If (Me.ViewState("VSMessageID") IsNot Nothing) Then return CType(Me.ViewState("VSMessageID "), Integer) else return 0 // arbitrary value End Get Set(value As Integer) Me.ViewState.Add("VSMessageID", value) End Set End Property Then : Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If (MessageID > 0) Then Fill(MessageID ) End If End Sub See http://msdn.microsoft.com/en-us/library/ms227551%28v=vs.85%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 Sorry if bad VB.Net synta

Categories : Asp Net

Set Window owner inside of an UserControl in WPF
for (int index=0;index< App.Current.Windows.Count;index++ ) { if (App.Current.Windows[index].Title == "MyWindow") control.Owner = App.Current.Windows[index]; } here Title is the Title of Window which you want to set as owner.

Categories : C#

Set value to TextBox in UserControl inside placeholder
Do not create an instance of a UserControl via constructor but with LoadControl as you have already done in Page_Load. However, you are doing that only if(!IsPostBack). Hence the control is instantiated the next postback via constructor. Also, you have to recreate dynamic controls on every postback. I would suggest to add the UserControl delaratively to the page. You can hide/show it accordingly. Otherwise you need to create/add it always, best in Page_Init instead of Page_Load. So this is not best-practise(just add it to the page) but should work as desired: IVT_FormClient ivtFormClient = null; protected void Page_Init(object sender, EventArgs e) { ivtFormClient =(IVT_FormClient)LoadControl("~/Evi/IVT/Sublayouts/IVT_FormClient.ascx"); Client UserClient = new Client(); Use

Categories : Asp Net

Can not create UserControl inside new AppDomain
I have found the mistake: var setup = new AppDomainSetup { ApplicationBase = rootAddInsPath, ........ }; var appDomain = AppDomain.CreateDomain(...) //I don't must do this here!!! appDomain.AssemblyResolve += (sender, args) => { .... } var managerType = typeof(AddInLoadManager); var manager =(AddInLoadManager)appDomain.CreateInstanceAndUnwrap(managerType.Assembly.FullName, managerType.FullName); Correct place for the "AppDomain.AssemblyResolve" event is inside of the "AddInLoadManager" class. Thanks for your help @YK1

Categories : C#

How to close dialog window from inside UserControl
You'll need to get at the active Window: var w = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive); if (w == null) { return; } w.Close();

Categories : Dotnet

Paint images on PictureBox inside a UserControl WPF
Instead of a PictureBox in a WindowsFormsHost you could simply use a WPF Image control: <StackPanel Orientation="Horizontal"> <Image x:Name="image" Height="440" Width="690" HorizontalAlignment="Left"/> ... </StackPanel> You would now create a BitmapImage from the Bitmap object using code as shown in this answer or in this answer, with an additional call to Freeze that makes it accessible in the UI thread: Bitmap bitmap = eventArgs.Frame; // your NewFrameEventArgs BitmapImage bitmapImage = new BitmapImage(); using (var stream = new MemoryStream()) { bitmap.Save(stream, ImageFormat.Bmp); stream.Seek(0, SeekOrigin.Begin); bitmapImage.BeginInit(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.StreamSource = stream; bitma

Categories : Wpf

Umbraco usercontrol: Get usercontrol.property.Id within the usercontrol itself?
Running round controls in a page or a usercontrol is simple enough (http://msdn.microsoft.com/en-us/library/20zys56y(v=vs.90).aspx) As is getting the properties of an object ((http://msdn.microsoft.com/en-us/library/aky14axb.aspx)) EG Running round the properties of any text boxes: ControlCollection controls = this.Controls; foreach(Control control in controls) { if (control.GetType().ToString() == "System.Web.UI.WebControls.TextBox") { // if this is the control you are interested in you can loop round its properties // something like foreach (var prop in control.GetProperties()) {

Categories : Asp Net

How can I change the Title from a Usercontrol in another cs?
I think you have a code like this... class someClass { UserControl1.Display = "Title"; } You cannot directly put your code inside a class like this, you have to create a method and then write this code inside that. For ex, change your code as below... class someClass { UserControl1 uc = new UserControl1(); public void some_Method() { uc.Display = "Title"; } }

Categories : C#

WPF: How to create Multiple instances of a UserControl inside a for loop with different name?
If you want to create your app in MVVM way don't use names and don't create user controls in your code. Create instances of view model class instead, add them to collection and bind the collection to ItemsControl (or similar control) ItemsSource property. Change the item template to render your control. <ItemsControl ItemsSource="{Binding ViewModels}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"></StackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <your:MyUserControl DataContext="{Binding}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

Categories : C#

Using converter to change backgroundcolor of usercontrol
Regardless of what the error is (this might even be it), I would like to point out that you really should check your input types in any Converter class: if (value == null || value.GetType() != typeof(YourRequiredType)) return DependencyProperty.UnsetValue;

Categories : C#

"WPF UserControl.Unloaded" tab change vs unload
The Unloaded-event is the wrong place to free unmanaged resources. http://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.100).aspx When you know that the UserControl is not needed anymore and want to free unmanaged resources immediatley - call Dispose()

Categories : C#

Change WPF UserControl depending on a Property of a TreeViewItem
The problem is that you are setting the Opacity directly on the control first. An explicit setting on a control will always override a trigger value. However, a trigger value will override a style setter. The following code should work (though I haven't tested it myself) <Controls:UcPerson Grid.Column="1" Grid.Row="1"> <Controls:UcPerson.Style> <Style TargetType="Controls:UcPerson"> <Style.Setters> <Setter Property="Opacity" Value="0" /> </Style.Setters> <Style.Triggers> <DataTrigger Binding="{Binding Path=Type, ElementName=OiTree.SelectedItem}" Value="Person"> <Setter Property="Opacity" Value="1"/> </DataTrig

Categories : Wpf

Checkboxlist inside a usercontrol going as null when control passed from an aspx page
In btnOK_Click you are creating a new instance of the user control and not attaching it to the page. My suggestion is: 1.Register the user control and add it to the page. <%@ Register Src="~/UserControl/SingleSelectCustomDropDown.ascx" TagPrefix="uc1" TagName="SingleSelectCustomDropDown" %> and ... <uc1:SingleSelectCustomDropDown runat="server" id="obj22" /> 2.Now modify in code behind: protected void btnOK_Click(object sender, EventArgs e) { if (chkSaveView.Checked) { if (!string.IsNullOrEmpty(txtViewName.Text)) { //some code here to save the view name from txtViewName to the DB //Do not create the control again //SingleSelectCustomDropDown obj22 = new SingleSelectCustomDropDown(); obj22.Pop

Categories : C#

how does a custom control in a usercontrol find the parent of the usercontrol in WPF?
Changing such stuff on a parent control directly from a child is generally frowned upon. Why don't you make this event in your child control a bubbling RoutedEvent to let the parent in the visual tree handle the event and action accordingly as it see's fit. Some helpful links: How to: Create a Custom Routed Event Extensive - Routed Events Overview Sample: A demo showing your use case where the MainWindow holds a UserControl which holds another UserControl within it and the MainWindow handles the custom event raised by the grand child UserControl. Download Link

Categories : Wpf

ASP.NET UserControl error - 'is not a member of 'System.Web.UI.UserControl'.'
I think WithEvents variable 'header' conflicts with property 'header' in the base class 'Page' and should be declared 'Shadows'. is creating problem. Try to resolve this error and see what happens.

Categories : Asp Net

Need to set DataContext of a UserControl from another UserControl both of which are on same WPF page
You can create a layout along these lines... <DockPanel> <Button DockPanel.Dock="Top" Content ="EDIT" Height="30" Width="150" Click="ButtonBase_OnClick" /> <TextBlock DockPanel.Dock="Top" Name="Control1" DataContext="{Binding}" Background="Yellow"/> <TextBlock DockPanel.Dock="Top" Name="Control2" Visibility="Collapsed" Background="Green"/> <Rectangle DockPanel.Dock="Top"></Rectangle> </DockPanel> And in the click handler, you can set the data context of the second control... private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { Control2.DataContext = Control1.DataContext; Control2.Visibility = Visibility.Visible; } This snippet makes the secon

Categories : Wpf

add Child DiV inside Parent Div programmatically in Asp.net
If you need to access HTML elements using ASP.NET, you have to add the runat="server" attribute to the element. Then, you can access it in server-side code using its ID, which will let you add child elements. See this answer for more information: Is there a way I can make a div runat server? So i can turn it into a control? For example: <div id="scrollContainer" runat="server"> </div>

Categories : Asp Net

Adding a View inside a ScrollView programmatically
My guess is that you're using the wrong LayoutParams. The LayoutParams of a view should have the type of its parent. In your case: tv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); Also, you are adding the TextView twice to your LinearLayout. ll.addView(tv); ll.addView(tv); Don't do this. Create a second TextView and add that if you need two TextViews in there. If these don't help, post your crash log from LogCat and I can help you from there.

Categories : Android

Change Tab Bar Programmatically
As @H2CO3 mentioned, there is no tabBarController property in NSTabView. If you read the documentation, you’ll notice that NSTabView provides a few selection methods, including -selectTabViewItemAtIndex:, which you can use like so: - (IBAction)startScratch:(id)sender { [_mainTabBar selectTabViewItemAtIndex:1]; } Note that the first tab is at index 0.

Categories : Objective C

How to detect the difference between a change made by a user and a change made programmatically?
If you just change the value with el.value = x, the change event is not triggered. For example, this won't log anything to the console: var el = document.getElementById('el') el.onchange = function(){ console.log('changed'); }; el.value = 'asasassasa'; So, if you're seeing it's being triggered twice, it's either because: You're manually triggering it with el.onchange(). In this case, just remove the this call. Or: The event handler is bound to the element more than once. You have to locate where that's happening.

Categories : Javascript

Run adb pull and push command from inside an application programmatically
Its not possible for Devices which are not rooted Since to run your command it requires Su permission (Super User) . Your command will be system/bin/ Su / -command non rooted device don't have access to system/bin/ Su you can root your emulator by Installing Superuser.apk or try How to get root access on Android emulator?

Categories : Android

Android - set button width programmatically inside a tablerow
Try This: LayoutParams lp = new TableRow.LayoutParams(android.widget.TableRow.LayoutParams.WRAP_CONTENT,android.widget.TableRow.LayoutParams.MATCH_PARENT); btn.setLayoutParams(lp); Try use Weight in button. Give table row weightsum=10. and divide it to buttons as per your req. like btn1.weight=3; btn2.weight=5;btn3.weight=2; this is like using % in HTML. if you set weightsum = 10 that means it will use 100% of its parent view. and using weight=3 for button means it will use 3/10 of total row size. it is just for width so you need to set width =0 for every view where you are assigning weight. for weight use like this: LayoutParams lp = new TableRow.LayoutParams(0,android.widget.TableRow.LayoutParams.MATCH_PARENT,3f); where 3f is weight. but first setweight sum to 10 in tablerow. Hop

Categories : Android

How do I create a textfield or label inside a cell programmatically?
Say you are setting your label like so: UILabel *label = [[UILabel alloc] initFrame:CGRectMake(0, 0, <width>, <height>)]; Try this: UILabel *label = [[UILabel alloc] initFrame:CGRectMake(-10, 0, <width>, <height>)];

Categories : IOS

How to get ContentControl to resolve DataTemplate
DataType design suggests the presence of a directive x:Type like that: <DataTemplate DataType="{x:Type system:DateTime}"> <Grid Background="Aqua"> <TextBlock Text="{Binding Day}" Height="30" Width="100" HorizontalAlignment="Center" /> </Grid> </DataTemplate> See the MSDN for more information.

Categories : Wpf

WPF - How to get ActualHeight of ContentControl's content?
Boris was right - my code now looks like this: <components:AnimateableContentControl x:Name="MainContent" Content="{Binding}"> <components:AnimateableContentControl.Triggers> <EventTrigger RoutedEvent="components:AnimateableContentControl.ContentChanged"> <BeginStoryboard> <Storyboard> <DoubleAnimation x:Name="TransitionAnimation" Storyboard.TargetName="MainContent" Storyboard.TargetProperty="Height" Duration="0:0:0.25" From="0" To="0" /> </Storyboard> </BeginStoryboard> </EventTrigger> </comp

Categories : Wpf

WPF binding with ContentControl not working
You cannot bind to fields, only properties, so change this: public Person PersonOne; to this: public Person PersonOne {get;set;} BTW, you probably need to create a ViewModel rather than putting the Data inside the Window itself.

Categories : Wpf

Bound ContentControl not displaying
You are right, as each Visual can have only one parent and since you have only one Path then last time it's used it will be put in that place of visual tree. What you can do is create Geometry resource: <Window.Resources> <!-- ..... --> <Geometry x:Key="myPath">M 20,4 L 36,20 L 32,24 L 23,15 L 23,33 L 17,33 L 17,15 L 8,24 L 4,20 Z</Geometry> </Window.Resources> and then you can use is in more then one Path: <Grid ...> <Ellipse Height="40" Width="40"> <Ellipse.Fill> <RadialGradientBrush GradientOrigin="0.3,0.3" Center="0.4,0.4"> <GradientStop Color="White" Offset="0"/> <GradientStop Color="Black" Offset="1"/> </RadialGradientBrush>

Categories : Wpf

How to hide ExtJS.Toolbar button( inside buttongroup ) programmatically
Try with Ext.get, Once i got the same problem, i resolve by replacing Ext.getCmp with Ext.get Try btn= Ext.get('b4_id'); btn.setVisible(false); or btn.hide(); if you like to hide initially, then use config as below. hidden: true Thanks

Categories : Extjs

Change Link in Workbook programmatically
Yes, there is. Use a simple Replace statement : Sub UpdateSheetName() Cells.Replace What:="OldSheetName", Replacement:="NewSheetName", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False End Sub If your workbook has other occurrences of the sheet name, and you don't want them to be caught by the search, use a limited range. Also, you can restrict by searching "OldSheetName!" (with the "!") and replacing by "NewSheetName!".

Categories : Excel

Change row height programmatically in ListView
The exception is thrown because the line: convertView = inflater.inflate(R.layout.row_shelf, parent); means you want to inflate the layout and add that inflated layout to the parent ViewGroup which will fail as ListView(being a child of AdapterView) doesn't allow direct child views addition. Instead you probably want: convertView = inflater.inflate(R.layout.row_shelf, parent, false); After that you can set the LayoutParams with the desired height(I would recommend that you use the proper LayoutParams, AbsListView.LayoutParams).

Categories : Android

Programmatically change SQL Server configuration
You do not have write permissions on drive C: for your custom user. EDIT: var query = @"BACKUP DATABASE [aveed_co] TO DISK = 'C:akup.bak' WITH INIT ,NOUNLOAD ,NAME = N'aveed_co' ,NOSKIP ,STATS = 10 ,NOFORMAT ,COMPRESSION"; using (var connection = new SqlConnection(@"Server=myServerAddress;Database=aveed_co;User Id=myUsername;Password=myPassword;")) { connection.Open(); using (var command = new SqlCommand(query, connection)) { command.CommandTimeout = 0; command.ExecuteNonQuery(); } } SQL Server must be abl

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.