Search Results

Search found 6301 results on 253 pages for 'wpf usercontrols'.

Page 15/253 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • WPF, UserControl, and Commands? Oh my!

    - by Greg D
    (This question is related to another one, but different enough that I think it warrants placement here.) Here's a (heavily snipped) Window: <Window x:Class="Gmd.TimeTracker2.TimeTrackerMainForm" xmlns:local="clr-namespace:Gmd.TimeTracker2" xmlns:localcommands="clr-namespace:Gmd.TimeTracker2.Commands" x:Name="This" DataContext="{Binding ElementName=This}"> <Window.CommandBindings> <CommandBinding Command="localcommands:TaskCommands.ViewTaskProperties" Executed="HandleViewTaskProperties" CanExecute="CanViewTaskPropertiesExecute" /> </Window.CommandBindings> <DockPanel> <!-- snip stuff --> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <!-- snip more stuff --> <Button Content="_Create a new task" Grid.Row="1" x:Name="btnAddTask" Click="HandleNewTaskClick" /> </Grid> </DockPanel> </Window> and here's a (heavily snipped) UserControl: <UserControl x:Class="Gmd.TimeTracker2.TaskStopwatchControl" xmlns:local="clr-namespace:Gmd.TimeTracker2" xmlns:localcommands="clr-namespace:Gmd.TimeTracker2.Commands" x:Name="This" DataContext="{Binding ElementName=This}"> <UserControl.ContextMenu> <ContextMenu> <MenuItem x:Name="mnuProperties" Header="_Properties" Command="{x:Static localcommands:TaskCommands.ViewTaskProperties}" CommandTarget="What goes here?" /> </ContextMenu> </UserControl.ContextMenu> <StackPanel> <TextBlock MaxWidth="100" Text="{Binding Task.TaskName, Mode=TwoWay}" TextWrapping="WrapWithOverflow" TextAlignment="Center" /> <TextBlock Text="{Binding Path=ElapsedTime}" TextAlignment="Center" /> <Button Content="{Binding Path=IsRunning, Converter={StaticResource boolToString}, ConverterParameter='Stop Start'}" Click="HandleStartStopClicked" /> </StackPanel> </UserControl> Through various techniques, a UserControl can be dynamically added to the Window. Perhaps via the Button in the window. Perhaps, more problematically, from a persistent backing store when the application is started. As can be seen from the xaml, I've decided that it makes sense for me to try to use Commands as a way to handle various operations that the user can perform with Tasks. I'm doing this with the eventual goal of factoring all command logic into a more formally-defined Controller layer, but I'm trying to refactor one step at a time. The problem that I'm encountering is related to the interaction between the command in the UserControl's ContextMenu and the command's CanExecute, defined in the Window. When the application first starts and the saved Tasks are restored into TaskStopwatches on the Window, no actual UI elements are selected. If I then immediately r-click a UserControl in the Window in an attempt to execute the ViewTaskProperties command, the CanExecute handler never runs and the menu item remains disabled. If I then click some UI element (e.g., the button) just to give something focus, the CanExecute handlers are run with the CanExecuteRoutedEventArgs's Source property set to the UI element that has the focus. In some respect, this behavior seems to be known-- I've learned that menus automat

    Read the article

  • How to pass EventArgument information from view to view model in WPF?

    - by Ashish Ashu
    I have ListView control in my application which is binded to the collection of CustomObject List<CustomObject. The CustomObject has seperate view. This ListView has seperate view model. The collection List _customobject is containted in the ListView ViewModel class. My Query: I want to invoke a view that show properties of custom object, when user double click on any row of ListView. The ListView double click command is binded to the ListViewDoublClick Command in the view model. The CustomObject is in the event argument of listview double click command. To acheive this I have to pass the custom object ( or an unique id property of custom object through which I can retrieve the custom object from the collection) as command parameter. Please suggest me the solution!!

    Read the article

  • In WPF 3D, why can't a perspective camera's LookDirection be straight down?

    - by DanM
    I'm attempting to position my perspective camera 30 units above the origin and pointing straight down. If I set the LookDirection of the camera to "0,0,-1", however, everything disappears. I have to make it "0.01,0.01,-1" for it to work. Why? <Window x:Class="ThreeDeeTester.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Viewport3D> <Viewport3D.Camera> <PerspectiveCamera Position="0,0,30" LookDirection="0.01,0.01,-1" UpDirection="0,0,1" /> <!-- LookDirection="0,0,-1" doesn't work...why? --> </Viewport3D.Camera> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup> <DirectionalLight Color="White" Direction="1,-1,-1" /> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions="0,0,10 -5,-5,0 -5,5,0 5,5,0 5,-5,0" TriangleIndices="2 1 0 2 0 3 4 3 0 1 4 0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Red" /> </GeometryModel3D.Material> </GeometryModel3D> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> </Viewport3D> </Grid> </Window>

    Read the article

  • Binding WPF ComboBox in XAML - Why is it Empty?

    - by mdiehl13
    I am trying to learn how to bind my simple database (.sdf) to a combobox. I created a dataset with my tables in it. I then dragged a table from the DataSource onto my control. There are no build warnings/errors, and when it runs, the ComboBox is empty. <UserControl x:Class="OurFamilyFinances.TabItems.TransactionTab" 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://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="414" d:DesignWidth="578" xmlns:my="clr-namespace:OurFamilyFinances" Loaded="UserControl_Loaded_1"> <UserControl.Resources> <my:FinancesDataDataSet x:Key="financesDataDataSet" /> <CollectionViewSource x:Key="accountViewSource" Source="{Binding Path=Account, Source={StaticResource financesDataDataSet}}" /> </UserControl.Resources> <Grid> <ComboBox DisplayMemberPath="Name" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource accountViewSource}}" Margin="3,141,0,0" Name="accountComboBox" SelectedValuePath="ID" VerticalAlignment="Top" Width="120"> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> </ComboBox> </Grid> The paths that is shows are correct, the selectedPath is "ID" and the displaypath is "Name". If I do this in Linq to Sql, the combo box does populate: this.accountComboBox.ItemsSource = from o in db.Account select new { o.ID, o.Name }; But I would like to learn how to do this in XAML. I have dragged datagrids from the DataSource as well, but they are not populated either. Any idea?

    Read the article

  • How do I bind one TabControl to the TabItems of another TabControl in WPF?

    - by joebeazelman
    I've defined the following TabControl called TabControl1: <TabControl> <TabItem Header="Cheese"> The Cheese Tab </TabItem> <TabItem Header="Pepperoni"> The Pepperoni Tab </TabItem> <TabItem Header="Mushrooms"> The Mushrooms Tab </TabItem> </TabControl> I've defined another TabControl, TabControl2 which is dynamically loaded from an add-in or plugin: <TabControl> <TabItem Header="Anchovies"> The AnchoviesTab </TabItem> <TabItem Header="Jalepenos"> The Jalepenos Tab </TabItem> <TabItem Header="Rattle Snake"> The Rattle Snake Tab </TabItem> </TabControl> After TabControl1 binds to TabControl2 after the "Cheese" item, TabControl1 should look like this: <TabControl> <TabItem Header="Cheese"> The Cheese Tab </TabItem> <TabItem Header="Anchovies"> The AnchoviesTab </TabItem> <TabItem Header="Jalepenos"> The Jalepenos Tab </TabItem> <TabItem Header="Rattle Snake"> The Rattle Snake Tab </TabItem> <TabItem Header="Pepperoni"> The Pepperoni Tab </TabItem> <TabItem Header="Mushrooms"> The Mushrooms Tab </TabItem> </TabControl>

    Read the article

  • Possible to Freeze Columns in a WPF ListView/GridView?

    - by Phil Sandler
    I currently have a GridView inside a ListView.View. The GridView columns will far exceed the width of the screen, so there will always be horizontal scrolling. What I would like to do is to have certain columns always remain on the screen regardless of scrolling. So the first x columns from the left are frozen (ala Excel), and the rest can scroll. It does not need to be dynamic/user selected--I know in advance which columns need to be frozen. Is this possible?

    Read the article

  • WPF Custom Control - Designer looks fine, but I get a runtime issue...

    - by myermian
    MainWindow.xaml <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:MyStuff;assembly=MyStuff" Title="MainWindow" Height="350" Width="525"> <Grid> <TabControl Margin="5"> <TabItem Header="Start Page" /> <my:XTabItem Header="Tab 1" Image="Resources/icon1.png" /> </TabControl> </Grid> </Window> Generic.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyStuff" > <!-- XTabItem --> <Style TargetType="{x:Type local:XTabItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:XTabItem}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <StackPanel Orientation="Horizontal"> <Image Source="{Binding Path=Image, RelativeSource={RelativeSource TemplatedParent}}" Stretch="UniformToFill" MaxHeight="24" /> <TextBlock Text="{TemplateBinding Header}" /> <Button Content="X" /> </StackPanel> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> XTabItem.cs using System; using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace MyStuff { public class XTabItem : TabItem { #region Dependency Properties public static readonly DependencyProperty ImageProperty; #endregion #region Constructors / Initializer static XTabItem() { //Initialize the control as "lookless". DefaultStyleKeyProperty.OverrideMetadata(typeof(XTabItem), new FrameworkPropertyMetadata(typeof(XTabItem))); //Setup the dependency properties. ImageProperty = DependencyProperty.Register("Image", typeof(ImageSource), typeof(XTabItem), new UIPropertyMetadata(null)); } #endregion #region Custom Control Properties (Image) /// <summary> /// The image (icon) displayed by inside the tab header. /// </summary> /// <remarks>The image is specified in XAML as an absolute or relative path.</remarks> [Description("The image displayed by the button"), Category("Optional Properties")] public ImageSource Image { get { return (ImageSource)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } } #endregion } } Exception at line #9 () : XamlParseException : 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '9' and line position '27'.

    Read the article

  • Should I inherit from a stackpanel instead of a stack panel, grid or other UI element or UserControl

    - by Joel Barsotti
    So I'm building a peice of UI that might me in a dialog window or might be in embedded in part of a bigger page. I don't have alot of experience with WPF, but in ASP.NET you always used UserControls, because their wasn't anyt really generic UI inherit to inherit from (and in a way UserControl was just a div). My coworker has written alot of controls that inherit directly from stackpanel. That seems like a decent way of doing things. But when I went to create a control for the code I was going to write I was presented with a dialog that only included the UserControl, which I wasn't that familiar with in the context of WPF. So can someone explain to me the difference from building a control that inherits from user control vs inheriting directly from a stackPanel?

    Read the article

  • How to get the default syle of my Button in WPF?

    - by Ashish Ashu
    I have create a Button style under Resource folder of the main application. I have added the reference of this button syle in the App.xml of the main application. Now this style is applicable to all the buttons in the main application or any other assembly. I want if I want to override my custom style of button to the normal button style , what should I do ?? Please help !!

    Read the article

  • WPF Storyboard works well, except for the first time it runs. Why?

    - by sofri
    Hi, I'm doing a Surface Application. And there I have something like a bulletin board where little cards with news on it are pinned on. On click they shall fly out of the board and scale bigger. My storyboard works well, except for the first time it runs. It's not a smooth animation then but it scales to its final size immediately and it's the same with the orientation-property. Just the center-property seems to behave correctly. This is an example for one of my Storyboards doing that: Storyboard stb = new Storyboard(); PointAnimation moveCenter = new PointAnimation(); DoubleAnimationUsingKeyFrames changeWidth = new DoubleAnimationUsingKeyFrames(); DoubleAnimationUsingKeyFrames changeHeight = new DoubleAnimationUsingKeyFrames(); DoubleAnimationUsingKeyFrames changeOrientation = new DoubleAnimationUsingKeyFrames(); moveCenter.From = News1.ActualCenter; moveCenter.To = new Point(250, 400); moveCenter.Duration = new Duration(TimeSpan.FromSeconds(1.0)); moveCenter.FillBehavior = FillBehavior.Stop; stb.Children.Add(moveCenter); Storyboard.SetTarget(moveCenter, News1); Storyboard.SetTargetProperty(moveCenter, new PropertyPath(ScatterViewItem.CenterProperty)); changeWidth.Duration = TimeSpan.FromSeconds(1); changeWidth.KeyFrames.Add(new EasingDoubleKeyFrame(266, KeyTime.FromTimeSpan(new System.TimeSpan(0, 0, 1)))); changeWidth.FillBehavior = FillBehavior.Stop; stb.Children.Add(changeWidth); Storyboard.SetTarget(changeWidth, News1); Storyboard.SetTargetProperty(changeWidth, new PropertyPath(FrameworkElement.WidthProperty)); changeHeight.Duration = TimeSpan.FromSeconds(1); changeHeight.KeyFrames.Add(new EasingDoubleKeyFrame(400, KeyTime.FromTimeSpan(new System.TimeSpan(0, 0, 1)))); changeHeight.FillBehavior = FillBehavior.Stop; stb.Children.Add(changeHeight); Storyboard.SetTarget(changeHeight, News1); Storyboard.SetTargetProperty(changeHeight, new PropertyPath(FrameworkElement.HeightProperty)); changeOrientation.Duration = TimeSpan.FromSeconds(1); changeOrientation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(new System.TimeSpan(0, 0, 1)))); changeOrientation.FillBehavior = FillBehavior.Stop; stb.Children.Add(changeOrientation); Storyboard.SetTarget(changeOrientation, News1); Storyboard.SetTargetProperty(changeOrientation, new PropertyPath(ScatterViewItem.OrientationProperty)); stb.Begin(this); News1.Center = new Point(250, 400); News1.Orientation = 0; News1.Width = 266; News1.Height = 400; Pin1.Visibility = Visibility.Collapsed; news1IsOutside = true; Scroll1.IsEnabled = true; What's wrong with it?

    Read the article

  • How does one bind to a List<DataRow> collection in WPF XAML?

    - by Elan
    Using a DataTable or DataView, one can specify the binding in XAML for example as follows: <Image Source="{Binding Thumbnail}" /> In my case I have created a List collection of DataRow objects and the above is not working. This is my data source: List<DataRow> I could of course convert the List< to a DataTable, but I am curious if there was a way to specify the binding in XAML to access the "Thumbnail" column within the DataRow that is stored in a List< collection. Elan

    Read the article

  • WPF Treeview: How to display rounded border around the selected item?

    - by chikak
    I am trying to set the rounded border around the selected item of the treeview (like the one in the windows explorer on Vista). The problem is that the trigger in the following code doesn't seem to be working. It looks like the IsSelected property is always false. <TreeView x:Name="m_treeView" BorderThickness="0" d:LayoutOverrides="Width, Height"> <TreeView.Resources> <Style TargetType="TreeViewItem"> <Style.Resources> <Brush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</Brush> </Style.Resources> </Style> </TreeView.Resources> <TreeView.ItemTemplate> <HierarchicalDataTemplate DataType="{x:Type local:DirectoryPresentationBase}" ItemsSource="{Binding Children}"> <TreeViewItem> <TreeViewItem.Header> <Border Name="SelectedBorder" CornerRadius="3" Background="#EFF8FD" BorderBrush="#99DEFD" BorderThickness="1" > <StackPanel Orientation="Horizontal"> <interactivity:Interaction.Behaviors> <local:TreeViewExpandBehavior AssociatedTreeView="{Binding ElementName=m_treeView}"/> </interactivity:Interaction.Behaviors> <Image x:Name="img" Width="24" Height="16" Stretch="None" Source="{Binding SmallIcon}"/> <TextBlock Text="{Binding Name}" Margin="5,0" /> </StackPanel> </Border> </TreeViewItem.Header> </TreeViewItem> <HierarchicalDataTemplate.Triggers> <Trigger Property="TreeViewItem.IsSelected" Value="True"> <Setter Property="Background" TargetName="SelectedBorder" Value="Red"/> <Setter Property="BorderBrush" TargetName="SelectedBorder" Value="Green"/> </Trigger> <Trigger Property="TreeViewItem.IsSelected" Value="False"> <Setter Property="Background" TargetName="SelectedBorder" Value="Transparent"/> <Setter Property="BorderBrush" TargetName="SelectedBorder" Value="Transparent"/> </Trigger> </HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView>

    Read the article

  • How does one bind to an List<DataRow> collection in WPF XAML?

    - by Elan
    Using a DataTable or DataView, one can specify the binding in XAML for example as follows: <Image Source="{Binding Thumbnail}" /> In my case I have created a List collection of DataRow objects and the above is not working. This is my data source: List<DataRow> I could of course convert the List< to a DataTable, but I am curious if there was a way to specify the binding in XAML to access the "Thumbnail" column within the DataRow that is stored in a List< collection. Elan

    Read the article

  • WPF: Turning off animations, data binding temporarly for invisible objects?;)

    - by TomTom
    I have a window that contains a tab control - basically multiple sheets with visualizations on them. The visualtizations are: possible very resource intensive during rendering relying on constant data updates to update their underlying models Obviously only one sheet can be visible every time ;) Anyone knows of a good way to turn off all visualization, animations, data binding for a control / panel and it's contained controls? If I would find a way to do that, I could simply turn off all the invisible sheets and reactivate them as needed. The models must be kept running - some of the visual stuff is pretty complex and really relies on constant data updates, and recalculating it when someone switches tabs would be too hard.

    Read the article

  • How to track which character is deleted in TextBox in WPF?

    - by Ashish Ashu
    I want to track which character is deleted by the user through Delete or BackSpace Key. I am handling RichTextBox_ChangedEvent of textbox. Can I extract the deleted character from TextChangedEventArgs *e.Changes* and if yes How can I do that? I want to restrict user to from deleting any characters from the TextBox. I want user can delete only two characters ( let's say "(" or ")" ) Please suggest.

    Read the article

  • WPF - How to style the menu control to remove the left margin?

    - by BrianLy
    I have added a default menu control into my user control. It is being combined with some other controls as part of a custom Window chrome. I need to style the menu to make it appear simpler. The main thing I need to do is to remove the left margin containing the space for the icon or checkbox. How can I do this? XAML: <Menu> <MenuItem Header="MyMeny" FontSize="10"> <MenuItem Header="Options..." /> <MenuItem Header="About" /> </MenuItem> </Menu>

    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

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >