Search Results

Search found 918 results on 37 pages for 'usercontrol'.

Page 3/37 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do I animate UserControl objects using Storyboard and DoubleAnimation?

    - by Neo
    In my WPF application, I have a Canvas object that contains some UserControl objects. I wish to animate the UserControl objects within the Canvas using DoubleAnimation so that they go from the right of the Canvas to the left of the Canvas. This is how I have done it so far (by passing the UserControl objects into the function): private void Animate(FrameworkElement e) { DoubleAnimation ani = new DoubleAnimation() { From = _container.ActualWidth, To = 0.0, Duration = new Duration(new TimeSpan(0, 0, 10), TargetElement = e }; TranslateTransform trans = new TranslateTransform(); e.RenderTransform = trans; trans.BeginAnimation(TranslateTransform.XProperty, ani, HandoffBehavior.Compose); } However, this doesn't allow me to pause the animation, so I have considered using a Storyboard instead to do this, but I'm not sure how to implement this. This has been my attempt so far: private void Animate(FrameworkElement e) { DoubleAnimation ani = new DoubleAnimation() { From = _container.ActualWidth, To = 0.0, Duration = new Duration(new TimeSpan(0, 0, 10), TargetElement = e }; Storyboard stb = new Storyboard(); Storyboard.SetTarget(ani, e); Storyboard.SetTargetProperty(ani, "Left"); stb.Children.Add(ani); stb.Begin(); } Of course, this fails as UserControl doesn't have a Left property. How can I achieve what I'm after? Thanks.

    Read the article

  • EF in a UserControl can't see the app.config?

    - by Sven
    I just created a user control. This control also makes use of my static Entity Framework class to load two comboboxes. All is well and runs without a problem. Design and runtime are working. Then when I stop the application all the forms that contain my UserControl don't work any more in design time. I just see two errors: Error1: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. Error 2: The variable ccArtikelVelden is either undeclared or was never assigned. (ccArtikelVelde is my UserControl) Runtime everything is still working My static EF Repositoy class: public class BSManagerData { private static BSManagerEntities _entities; public static BSManagerEntities Entities { get { if (_entities == null) _entities = new BSManagerEntities(); return _entities; } set { _entities = value; } } } Some logic happening in my UserControl to load the data in the comboboxes: private void LaadCbx() { cbxCategorie.DataSource = (from c in BSManagerData.Entities.Categories select c).ToList(); cbxCategorie.DisplayMember = "Naam"; cbxCategorie.ValueMember = "Id"; } private void cbxCategorie_SelectedIndexChanged(object sender, EventArgs e) { cbxFabrikant.DataSource = from f in BSManagerData.Entities.Fabrikants where f.Categorie.Id == ((Categorie)cbxCategorie.SelectedItem).Id select f; cbxFabrikant.DisplayMember = "Naam"; cbxFabrikant.ValueMember = "Id"; } The only way to make my forms work again, design time, is to comment out the EF part in the UserControl (see above) and rebuild. It's very strange, everything is in the same assembly, same namespace (for the sake of simplicity). Anyone an idea?

    Read the article

  • How can I clear viewstate of a dropdownlist inside a usercontrol? Should I?

    - by tbilly
    I have a web user control with a dropdownlist inside of it. When the usercontrol's databind event is called, it automatically fires the dropdownlists databind event. In the dropdownlist's ondatabound event handler an 'other' option is appended to the end of the dropdownlist. The usercontrol is loaded multiple times, depending on selection of other controls on the page. When the page loads initially, there are no items in the usercontrol except the 'other' option. Then when I call the user control's databind event the control reloads, with 4 items plus the 'other' option. The text for the first item in the list is the 'other' option's text, not what it should be. I've stepped through the databound event of the dropdownlist and have found that all items are loading correctly. It appears that the dropdownlist's viewstate is the culprit, that the dropdownlist's original item[1] text is overwriting the new text. I've tried disabling viewstate on the dropdownlist, but then it wouldn't load at all. Should I try to clear the dropdownlist's viewstate? How do I do that? Any suggestions would be greatly appreciated.

    Read the article

  • UserControl as ListBoxItem and IsSelected

    - by mattjf
    I have a usercontrol that I want to use as a ListBoxItem. <ListBox.ItemTemplate> <DataTemplate> <local:MyUserControl/> </DataTemplate> </ListBox.ItemTemplate> I'd like to play a storyboard when the usercontrol is unselected. <UserControl.Resources> <Style TargetType="{x:Type UserControl}"> <Style.Triggers> <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="False"> <DataTrigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource OnMouseLeaveSB}"/> </DataTrigger.EnterActions> </DataTrigger> </Style.Triggers> </Style> </UserControl.Resources> But the storyboard is never firing. Is there a better way to do this? Edited to Add: What I am really trying to accomplish this this: When the mouse is over the UserControl, I want to play a storyboard (OnMouseEnterSB). When the mouse leaves the UserControl, I want to play another storyboard (OnMouseLeaveSB). I have all this working fine. When the UserControl is selected, however, and the mouse leaves, I do NOT want to play the storyboard. Finally, when the UserControl is unselected, I want to play the OnMouseLeaveSB storyboard.

    Read the article

  • UserControl/TreeView Problem....Not getting result during runtime..

    - by Samiul
    Hi all, My problem is, I'm using a TreeView in a UserControl. While debugging, I can see the results are adding in the TreeView but it's not happening when I'm using that UserControl onto my MainForm. The UserControl containing the TreeView remains blank during runtime of the main application. I've also referenced the UserControl project with my Main project. Here I'm giving my code for helping me out. Thanks in advance. Code: In the UserControl class: public override void Refresh() { PopulateTreeView(); } private void PopulateTreeView() { TreeNodeCollection treeNodeCollection; treeNodeCollection = CreateParentNode("My Information"); CreateChildNode(treeNodeCollection, "Name"); CreateChildNode(treeNodeCollection, "Address"); this.Update(); myTreeView.ExpandAll(); } private TreeNodeCollection CreateParentNode(string parentNode) { TreeNode treeNode = new TreeNode(parentNode); myTreeView.Nodes.Add(treeNode); return treeNode.Nodes; } private void CreateChildNode(TreeNodeCollection nodeCollection, string itemName) { TreeNode treeNode = new TreeNode(itemName); nodeCollection.Add(treeNode); } In my MainForm: private void button1_Click(object sender, EventArgs e) { UserControl userControl = new UserControl(); userControl.Refresh(); }

    Read the article

  • ImageViewer UserControl

    The article is about a UserControl I wrote. Opposed to PictureBoxes and other methods to displaying images on your forms this one provides a totally diffrent approach.

    Read the article

  • How can I avoid properties being reset at design-time in tightly bound user controls?

    - by David Anderson
    I have UserControl 'A' with a label, and this property: /// <summary> /// Gets or Sets the text of the control /// </summary> [ Browsable(true), EditorBrowsable(EditorBrowsableState.Always), Category("Appearance") ] public override string Text { get { return uxLabel.Text; } set { uxLabel.Text = value; } } I then have UserControl 'B' which has UserControl 'A' on it, and I set the Text Property to "My Example Label" in the designer. Then, I have my MainForm, which has UserControl 'B' on it. Each time I do a build or run, the Text property of UserControl 'A' is reset to its default value. I suppose this is because since I am doing a rebuild, it rebuilds both UserControl 'A' and 'B', thus causing the problem. How can I go about a better approach to design pattern to avoid this type of behavior when working with tightly bound controls and forms in a application?

    Read the article

  • When should I use a UserControl instead of a Page?

    - by dthrasher
    I notice that many of the WPF MVVM frameworks seem to avoid using the NavigationWindow and Page controls in favor of composing pages using nested UserControls. The NavigationWindow and Page provide easy ways to enable back and forward navigation in the journal as well as providing an easy way to pass data among pages. Most MVVM frameworks I've seen re-implement these features in various ways. Is there a specific reason to avoid using NavigationWindow and Page?

    Read the article

  • WPF - How do I use the UserControl with a dependency property and view model?

    - by user320849
    Hello, My goal is to have a user select a year and a month. Translate the selection into a date and have the user control send the date back to my view model. That part works for me....However, I cannot get the ViewModel's initial date to set those drop downs. public static readonly DependencyProperty Date = DependencyProperty.Register("ReturnDate", typeof(DateTime), typeof(DatePicker), new FrameworkPropertyMetadata{BindsTwoWayByDefault = true,}); public DateTime ReturnDate { get { return Convert.ToDateTime(GetValue(Date)); } set { SetDropDowns(value); SetValue(Date, value); } } The SetDropDowns(value) just sets the selected items on the combo boxes, however, the program never makes it to that method. On the view I am using: <cc1:DatePicker ReturnDate="{Binding Path=StartDate, Mode=TwoWay}" IsStart="True" /> If this has been answered, then my bad. I looked around and didn't see anything that worked for me. Thus, when the program loads how do I get the value from the view model to a method in order to set the combo boxes? Thanks, -Scott

    Read the article

  • Get parent page values from the usercontrol

    - by Nimesh
    How to get the parent page values from the usercontrol. I have a usercontrol in a page. On click of the usercontrols button i wanna get some values from the page after executing a method. i need those values in my usercontrol. What is the best way to get the results of the page in the usercontrol.

    Read the article

  • User defined top level control in XAML

    - by luke
    A normal UserControl looks like this in XAML: <UserControl x:Class="mynamespace.foo" ...namespaces...> <!-- content --> </UserControl> I'd like to be able to define my own top level object, along the lines of: <MyControl x:Class="mynamespace.mycontrol" ...namespaces...> <!-- content --> </UserControl> Where MyControl derives from a UserControl itself. Of course the compiler complains about "MyControl" not being found. Is there a way around this?

    Read the article

  • Problem with usercontrol scaling when added at run-time in .Net, WinForms

    - by Jules
    First here's the steps to replicate, then I'll explain what the problem is: (1) Add a usercontrol to a form in the construtor, after the InitializeComponent call. (2) Run the form. (3) Click a button to increase the form font size. All the controls within the usercontrol scale perfectly but the usercontrol itself doesn't. It's width and height are increased by way too much. To correct the problem, the usercontrol must be added before the InitializeComponent call. If it wasn't possible for me to add the usercontrol before InitializeComponent, is there any way for me to correct the scaling?

    Read the article

  • Custom CheckBoxList in ASP.NET

    - by Rick
    Since ASP.NET's CheckBoxList control does not allow itself to be validated with one of the standard validation controls (i.e., RequiredFieldValidator), I would like to create a UserControl that I can use in my project whenever I need a checkbox list that requires one or more boxes to be checked. The standard CheckBoxList can be dragged onto a page, and then you can manually add <asp:ListItem> controls if you want. Is there any way I can create a UserControl that lets me manually (in the markup, not programmatically) insert ListItems from my page in a similar manner? In other words, can I insert a UserControl onto a page, and then from the Designer view of the Page (i.e., not the designer view of the UserControl), can I manually add my ListItems like so: <uc1:RequiredCheckBoxList> <asp:ListItem Text="A" value="B"></asp:ListItem> <asp:ListItem Text="X" value="Y"></asp:ListItem> </uc1:RequiredCheckBoxList> If a UserControl is not the appropriate choice for the end result I'm looking for, I'm open to other suggestions. Please note that I am aware of the CustomValidator control (which is how I plan to validate within my UserControl). It's just a pain to write the same basic code each time I need one of these required checkbox lists, which is why I want to create a re-usable control.

    Read the article

  • WPF DataGrid binding to UserControl

    - by Trindaz
    I have a DataGrid with one column using a UserControl via a styled DataGridTemplateColumn. I can't seem to get the UserControl to 'see' the object that is in it's containing DataGridCell though. What kind of bindings can I create on the TextBox in my UserControl so that it can look up and see that object?! My UserControl and TemplateColumn Style are defined as: <Window.Resources> <local:UCTest x:Key="UCTest" /> <Style x:Key="TestStyle" TargetType="{x:Type WpfToolkit:DataGridCell}"> <Style.Setters> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WpfToolkit:DataGridCell}"> <Grid Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource drc}, Path=DataContext}"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <local:UCTest /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style.Setters> </Style> </Window.Resources> and my sample DataGrid is defined as: <WpfToolkit:DataGrid Name="dgSampleData" ItemsSource="{Binding}" AutoGenerateColumns="True" Margin="0,75,0,0"> <WpfToolkit:DataGrid.Columns> <WpfToolkit:DataGridTemplateColumn Header="Col2" CellStyle="{StaticResource TestStyle}" /> </WpfToolkit:DataGrid.Columns> </WpfToolkit:DataGrid> and my User Control is defined in a separate file as: <UserControl x:Class="UCTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-namespace:WpfApplication1" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="104" Height="51"> <UserControl.Resources> <local:DataRowConverter x:Key="drc" /> </UserControl.Resources> <Grid> <TextBox Margin="12,12,-155,16" Name="TextBox1" Text="" /> </Grid> EDIT: My implementation of TestClass, which has the Test Property, which I want UCTest.TextBox1 to bind do: Public Class TestClass Private _Test As String = "Hello World Property!" Public Property Test() As String Get Return _Test End Get Set(ByVal value As String) _Test = value End Set End Property End Class Thanks in advance!

    Read the article

  • AvalonDock + UserControl + DataGrid + ContextMenu command routing issue

    - by repka
    I have this kind of layout: <Window x:Class="DockAndMenuTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" Title="MainWindow" Height="350" Width="525"> <ad:DockingManager> <ad:DocumentPane> <ad:DockableContent Title="Doh!"> <UserControl> <UserControl.CommandBindings> <CommandBinding Command="Zoom" Executed="ExecuteZoom" CanExecute="CanZoom"/> </UserControl.CommandBindings> <DataGrid Name="_evilGrid"> <DataGrid.Resources> <Style TargetType="DataGridRow"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu> <MenuItem Command="Zoom"/> </ContextMenu> </Setter.Value> </Setter> </Style> </DataGrid.Resources> </DataGrid> </UserControl> </ad:DockableContent> </ad:DocumentPane> </ad:DockingManager> </Window> Briefly: ContextMenu is set for each DataGridRow of DataGrid inside UserControl, which in its turn is inside DockableContent of AvalonDock. Code-behind is trivial as well: public partial class MainWindow { public MainWindow() { InitializeComponent(); _evilGrid.ItemsSource = new[] { Tuple.Create(1, 2, 3), Tuple.Create(4, 4, 3), Tuple.Create(6, 7, 1), }; } private void ExecuteZoom(object sender, ExecutedRoutedEventArgs e) { MessageBox.Show("zoom !"); } private void CanZoom(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; } } So here's the problem: right-clicking on the selected row (if it it was selected before the right click) my command comes out disabled. The command is "Zoom" in this case, but can be any other, including a custom one. If I get rid of either docking or UserControl around my grid there are no problems. ListBox doesn't have this issue either. So I don't know what's at fault here. SNOOP shows that in cases when this propagation fails, instead of UserControl, CanExecute is handled by PART_ShowContextMenuButton (Button), which is part of docking header. I've had other issues with UI command propagation within UserControls hosted inside AvalonDock, but this one is the easiest to reproduce.

    Read the article

  • Displaying Tweets in an ASP.NET UserControl with TweetSharp

    As I mentioned in my previous blog post, I'll be having a little fun over the next few weeks talking about all of the Social Media APIs I've been experimenting with. I thought I would start out today by talking about one of the most popular services, Twitter. Twitter is essentially a microblogging service that allows its users to post messages of up to 140 characters long known as Tweets. Users can subscribe to each other and see tweets from all of their subscriptions in their main feed listings. Due to this ease of providing and receiving updates to and from the masses, Twitter has been adopted by anything from bloggers to celebrities to large corporations. If you have a blog or just a website in general, having a Twitter account alongside it could potentially be a useful way to attract new visitors. Displaying your tweets on your website and ...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • I got MVVM 3-Level-Master-Detail Switchting working but with CRUD operations now everything seems st

    - by msfanboy
    Hello, I have 1 UserControl (SchoolclassAdministration.xaml) that is datatemplated with 1 ViewModel (SchoolclassAdministrationViewModel) I have 3 Models and 3 ViewModels in that scenario. Those 3 ViewModels must reflect the requirements of the View. The requirements are 3 "Areas" on the left side and 2 "Areas" on the right side. 3: SchoolclassFormular PupilFormular SubjectFormular Those have all Buttons for Add/Delete 2: PupilsDataGrid SubjectsDataGrid The Master-Detail scenario is between the: SchoolclassFormular = PupilsDataGrid = SubjectsDataGrid The switching of the ViewModelCollections work! My Problem scenario is this: The DataContext is on the SchoolclassAdministrationViewModel what is the ViewModel containing the AllSchoolclassesViewModel ObservableCollection bound to the SchoolclassAdministration.xaml UserControl. My SchoolclassViewModel,PupilViewModel and SubjectViewModel has all Properties, Commands(Add/Delete). My Question: How can I set these 3 ViewModels as DataContext to my ONE SchoolclassAdministration.xaml UserControl I have? Before you answer... putting every ViewModel(schoolclass,pupil,subject) in its own UserControl will not help me because then the Master-Detail switching can NOT work anymore. Every related ViewModels need to be put in a related/ONE UserControl. OK now I can`t wait for an answer because that scenario is driving me nuts for weeks.

    Read the article

  • How to aggregate bindings in Silverlight UserControl

    - by Peter Wone
    Imagine a UserControl containing some sort of ItemsControl. The UserControl as a whole has a DataContext, but you also need to expose the ItemsSource of the ItemsControl. I have tried all manner of arrangements, and eventually passed a DomainDataSource as a UserControl dependency property named DDS, and bound the ItemsControl like this: ItemsSource="{Binding DDS.Data, ElementName=userControl}" It works, but this is mucky, and with Silverlight mucky is nearly always a sign of incorrect approach. Your advice is sought. It looks like multi-bindings might be the answer to this.

    Read the article

  • UserControl that is also a Grid in WPF

    - by drasto
    I would like to create a UserControl that will have some behavior(animated collapsing...) and some Controls in it (Rectangle, Ellipse, mostly for design purposes). However I need it to be a valid Panel like Grid so I can put more controls in it when designing main window. Controls that will be add to the new USerControl in main window design time does not need to interact with components that are added to it when creating a UserControl. How should I do this ? Do I have to extends Control? I'd prefer to extend just UserControl.

    Read the article

  • jQuery logic firing twice from a Usercontrol when used in a jQueryUI modal dialog

    - by AaronS
    I have an asp.net usercontrol that I'm using to put a bunch of HTML and Jquery logic into to be shared on several pages. This usercontrol has some dropdown boxes loaded from json calls and has no added codebehind logic. When I use this usercontrol on a normal page it works perfectly fine, and no issues at all. However, when I wrap the usercontrol in a div, and use a jqueryUI modal dialog, everything in the usercontrol fires twice. Not only code in the initial $(document).ready(function() {});, but also every function is also fired twice when called. Debugging this in Visual Studio, I see that everything is first being called from the external JS file, and then again from a "script block" file that is somehow getting generated on the fly. This script block file isn't getting generated on a page that doesn't wrap the user control in a modal. The same happens if I use IISExpress or IIS7. The question is, why is this script block file getting created, and why is all my jQuery logic firing twice? --edit-- Here is the div: <div id="divMyDiv" title="MyDiv"> <uc1:MyUserControl runat="server" ID="MyUsercontrol" /> </div> Here is the modal logic that uses it: $("#divMyDiv").dialog({ autoOpen: false, height: 400, width: 400, modal: true, open: function (type, data) { $(this).parent().appendTo("form"); } }); Note: The problm still occurs, even if I remove the "open:" function. But, it does not occur if I remove the entire dialog block, so it is specific to this dialog call.

    Read the article

  • Page_load filling data after loading UserControl ASP.net

    - by msytNadeem
    I have an aspx Page that contain a userControl that contains textboxes. in the page_load method, it reads from the database, and i want to fill the textboxes of the usercontrol with the data been read. the problem i am facing, that the flow of page loading is Page_Load of the page, where i am assigning the text field, then it page_load of the userControl, so here all the data will be erased, then it will show the page. how i can fix this.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >