Search Results

Search found 10936 results on 438 pages for 'wpf controls'.

Page 10/438 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • WPF - Setting usercontrol width using triggers and mouseenter event

    - by BigBadJock
    I have a wrap panel full of usercontrols. When I hover the mouse over a usercontrol I want it to expand to show more details. Some stripped down sample code: <UserControl x:Class="WPFTestBed.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300"> <UserControl.Resources> </UserControl.Resources> <UserControl.Triggers> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <EventTrigger.Actions> <Setter TargetName="WPFTestBed.UserControl1" Property="Control.Width" Value="200"/> </EventTrigger.Actions> </EventTrigger> </UserControl.Triggers> <Grid Height="95" Width="123"> <Button Height="23" HorizontalAlignment="Left" Margin="17,30,0,0" Name="button1" VerticalAlignment="Top" Width="75">Button</Button> </Grid> </UserControl> I would appreciate it if someone could point out where I'm going wrong, and set me down the correct path. Ideally, I want the usercontrol to delay for x seconds when there is a mouseover, before expanding and showing the extra details.

    Read the article

  • wpf - window to be tight round user control

    - by Andy Clarke
    Hi, I've got a user control that I'm loading into a Window dynamically - I wanted to set the Window so that it didn't have a size and then I thought the window to resize accordingly depending on the UserControl. However it dosn't - can anyone assist please? I've made a very basic example - I've cut out the dynamic bits and just put a UserControl in a Window. What do I need to do to get the window to be tight around the UserControl? Thanks, Andy <UserControl x:Class="WpfApplication1.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300" Background="LightBlue"> <Grid> </Grid> </UserControl> <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:WpfApplication1="clr-namespace:WpfApplication1" Title="Window1" > <Grid> <WpfApplication1:UserControl1> </WpfApplication1:UserControl1> </Grid> </Window>

    Read the article

  • Create a grid in WPF as Template programmatically

    - by wickie79
    I want to create a basic user control with a style programmatically. In this style i want to add a Grid (no problem), but i dont can add column definitions to this grid. My example code is ControlTemplate templ = new ControlTemplate(); FrameworkElementFactory mainPanel = new FrameworkElementFactory(typeof(DockPanel)); mainPanel.SetValue(DockPanel.LastChildFillProperty, true); FrameworkElementFactory headerPanel = new FrameworkElementFactory(typeof(StackPanel)); headerPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); headerPanel.SetValue(DockPanel.DockProperty, Dock.Top); mainPanel.AppendChild(headerPanel); FrameworkElementFactory headerImg = new FrameworkElementFactory(typeof(Image)); headerImg.SetValue(Image.MarginProperty, new Thickness(5)); headerImg.SetValue(Image.HeightProperty, 32d); headerImg.SetBinding(Image.SourceProperty, new Binding("ElementImage") { RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) }); headerPanel.AppendChild(headerImg); FrameworkElementFactory headerTitle = new FrameworkElementFactory(typeof(TextBlock)); headerTitle.SetValue(TextBlock.FontSizeProperty, 16d); headerTitle.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center); headerTitle.SetBinding(TextBlock.TextProperty, new Binding("Title") { RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) }); headerPanel.AppendChild(headerTitle); FrameworkElementFactory mainGrid = new FrameworkElementFactory(typeof(Grid)); FrameworkElementFactory c1 = new FrameworkElementFactory(typeof(ColumnDefinition)); c1.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star)); FrameworkElementFactory c2 = new FrameworkElementFactory(typeof(ColumnDefinition)); c2.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Auto)); FrameworkElementFactory c3 = new FrameworkElementFactory(typeof(ColumnDefinition)); c3.SetValue(ColumnDefinition.WidthProperty, new GridLength(3, GridUnitType.Star)); FrameworkElementFactory colDefinitions = new FrameworkElementFactory(typeof(ColumnDefinitionCollection)); colDefinitions.AppendChild(c1); colDefinitions.AppendChild(c2); colDefinitions.AppendChild(c3); mainGrid.AppendChild(colDefinitions); mainPanel.AppendChild(mainGrid); FrameworkElementFactory content = new FrameworkElementFactory(typeof(ContentPresenter)); content.SetBinding(ContentPresenter.ContentProperty, new Binding() { RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent), Path = new PropertyPath("Content") }); mainGrid.AppendChild(content); templ.VisualTree = mainPanel; Style mainStyle = new Style(); mainStyle.Setters.Add(new Setter(UserControl.TemplateProperty, templ)); this.Style = mainStyle; But the creation of FrameworkElementFactory with type ColumnDefinitionCollection will throw an exception "'ColumnDefinitionCollection' type must derive from FrameworkElement, FrameworkContentElement, or Visual3D." Who can help me?

    Read the article

  • ComboBox wpf not item not being selected

    - by Greg R
    I am trying to bind a combo box to a list of objects, and it works great, besides the selected value, am I missing somethign? <ComboBox ItemsSource="{Binding OrderInfoVm.AllCountries}" SelectedValuePath="country_code" DisplayMemberPath="country_name" SelectedValue="{Binding OrderInfoVm.BillingCountry}" /> Basically I want to bind value to country codes and set the selected value to the country code bound to OrderInfoVm.BillingCountry (which implements INotifyPropertyChanged) Initially when the control loads selected value is empty, but on click BillingCountry is populated. Selected value does not seem to change. How can I remedy that?

    Read the article

  • ListView containing Bitmaps with Zoom Animation in WPF

    - by Ashish Ashu
    I have a simple requirement as mentioned below: A ListView or any control displays list of bitmaps/images. When user mouse hovers on any bitmap that bitmap zoomed to show that is currently selected. Since I have to provide drag drop operations and click operation that why I taken the list view. Pleas help!! It will be great if any body provide the xaml to this..

    Read the article

  • To show the help related information in WPF.

    - by Ashish Ashu
    I have several dialogs in the application. I want to pop up help related box when user clicks on the help button next to Main Heading. The help box is activated by selecting the small blue icon next to the heading. When the help box appears it has the information that is required to understand the entry related to the dialog. This help box automatically disappears when user clicks any where other then the help box. Please help!!

    Read the article

  • Date Picker Today Option In WPF

    - by Asim Sajjad
    Is there any property , option available in the date picker control so that if user want to select today from any date from current date ? e.g if user is view current month of last year then he has the option to select current date ?

    Read the article

  • Why does WPF toggle button pulse once unchecked

    - by randyc
    Wihtin a Desktop app I have a toggle button: For the Checked event I am setting a value and then executing a method FilterView(); //ommitting code Unchecked state is just the opposite. resets a variable and executed the method again The question I have is I noticed when I uncheck the toggle button the button continues to pulse or flash ( going from blue to chrome) as if it still has focus. The button will stay like this until another button is clicked. Is there a way to remove this focus so that when the button is unchecked the button goes back to a unchecked state without the flashing / pulsing color. As you can see from above this is a standard toggle button no styles or custom I tested this on just a regular button and I found the same occured when clicked the button will continue to pulse / flash until another button is clicked. How do you work around this or prevent this effect from happening. Thank you

    Read the article

  • WPF TextBlock binding with <LineBreak/>

    - by Vinjamuri
    I have a TextBlock binding as follows in my ControlTemplate. When I set ButtonText as follows with , it doesn't work. It doesn't display in separate line. ButtonText="Change Casette" How to fix this? Appreciate your help, please provide me with sample code.

    Read the article

  • Wpf nesting containers

    - by dortzur
    On a window control, my main container is a grid. My grid has 2 rows, one row definition is 50*, and the other is 250*. Now i want to add a right sidebar, lets say with a StackPanel. I would like to have a ListBox inside the StackPanel that aligns with the 50* grid row, so as the window height gets bigger, the ListBox size will also get bigger. My question is whether i can achieve this behavior while the ListBox is inside the StackPanel (which is nested inside the grid) or must the ListBox be placed directly inside the grid?

    Read the article

  • WPF designer gives exception when databinding a label to a checkbox

    - by John
    I'm sure it's something stupid, but I'm playing around with databinding. I have a checkbox and a label on a form. What I'm trying to do is simply bind the Content of the label to the checkbox's IsChecked value. What I've done runs fine (no compilation errors and acts as expected), but if I touch the label in the XAML, the designer trows an exception: System.NullReferenceException Object reference not set to an instance of an object. at MS.Internal.Designer.PropertyEditing.Editors.MarkupExtensionInlineEditorControl.BuildBindingString(Boolean modeSupported, PropertyEntry propertyEntry) at <Window x:Class="UnitTestHelper.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:FileSysCtls="clr-namespace:WPFFileSystemUserControls;assembly=WPFFileSystemUserControls" xmlns:HelperClasses="clr-namespace:UnitTestHelper" Title="MainWindow" Height="406" Width="531"> <Window.Resources> <HelperClasses:ThreestateToBinary x:Key="CheckConverter" /> </Window.Resources> <Grid Height="367" Width="509"> <CheckBox Content="Step into subfolders" Height="16" HorizontalAlignment="Left" Margin="17,254,0,0" Name="chkSubfolders" VerticalAlignment="Top" Width="130" IsThreeState="False" /> <Label Height="28" HorizontalAlignment="Left" Margin="376,254,0,0" Name="lblStepResult" VerticalAlignment="Top" Width="120" IsEnabled="True" Content="{Binding IsChecked, ElementName=chkSubfolders, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource CheckConverter}}" /> </Grid> The ThreeStateToBinary class is as follows: class ThreestateToBinary : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((bool)value) return "Checked"; else return "Not checked"; //throw new NotImplementedException(); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ((string)value == "Checked"); //throw new NotImplementedException(); } #endregion } Quite honestly, I'm playing around with it at this point. It was originally simpler (not using the ValueConverter) but was displaying similar behavior when I simply had the content set to: Content="{Binding IsChecked, ElementName=chkSubfolders, UpdateSourceTrigger=PropertyChanged}" Any ideas? Thanks, John

    Read the article

  • WPF: Databinding and Combo Boxes

    - by Jonathan Allen
    I have two classes Company CompanyKey CompanyName Person FirstName LastName CompanyKey The list items on the combo box is bound to a collection of CompanyObjects. How to I databind the selected item property of the Combobox to the Person.CompanyKey property?

    Read the article

  • WPF ComboBox Object Binding - not updating DataContext Object

    - by Jaysen
    Hello, I have the following scenario: 1 class called 'Widget' with the properties: ID, Code, Description 1 class called 'MyWidget' with a property: m_Widget As Widget 1 ComboBox The ComboBox has a List(Of Widget) set as the ItemSource. I create an instance of 'MyWidget' named MyWidget1 and I set the property values of the m_Widget to match one of the items in the 'ComboBox List(Of Widget)'. I then set the DataContext of the ComboBox to MyWidget1.Widget. When I change the ComboBox selected item, only the ID property of 'MyWidget1.Widget' gets updated... How do I get the object 'Widget' on 'MyWidget1' to be updated instead of just 'MyWidget1.Widget.ID'? Here is a link to a sample project demonstrating this scenario: http://www.webpersona.com/ObjectBinding.zip Thanks in advance for any help :)

    Read the article

  • WPF StringFormat={0:C} showing as dollars

    - by Coesy
    Why does this line of code <TextBlock Text="{Binding Net, StringFormat=c}"/> Output the result as $xx.xx when all my regional settings are set to UK. I expect it to output it as £xx.xx. Any ideas? I have tried different variations of the stringformat including StringFormat={}{0:C} but still get the same result. Thanks for looking.

    Read the article

  • WPF DataGrid default column types

    - by Trindaz
    Hi, I'm using a DataGrid to display 2 possible types of DataRow in a DataTable. One type has the column Parent = NULL and the other has Parent set to another DataRow in the same DataTable. The list of column in the DataTable is always different, so explicitly describing each column is not possible. I want to display a UserControl in every cell of the Parent = DataRow rows, and default Text / Check boxes for the Parent = NULL rows. My first strategy is to try and set the default Column type for all automatically generated columns to be a DataGridTemplateColumn, regardless of datatype, so that I can use styles to then use either my UserControl or CheckBox or TextBox where required. How can I do this? More importantly, though, is there a better strategy than this? Cheers, Dave

    Read the article

  • WPF DataGrid - Can't Use Mouse To Scroll Because Of Drag Drop

    - by OrPaz
    Hello, I am using a datagrid that is allowing to drag its rows. My problem is that when i try to scroll down on my grid using the mouse on the side scroller, i get the 'no enterance' sign that means that "drag and drop is not allowed here, dude...". How can i modify my drag and drop function to recognize that this is not a drag and drop action, but a scroll mouse action? private new void MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPosition = e.GetPosition(GridUC); Object selectedItem = GridUC.SelectedItem; if (selectedItem == null) return; DragDropContainerObject ddObject = new DragDropContainerObject(typeof(Actor), selectedItem); DataGridRow container = (DataGridRow)GridUC.ItemContainerGenerator.ContainerFromItem(selectedItem); if (container != null) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(container, ddObject, DragDropEffects.Link); } } }

    Read the article

  • When will the ValueConverter's Convert method be called in wpf

    - by sudarsanyes
    I have an ObservableCollection bound to a list box and a boolean property bound to a button. I then defined two converters, one that operates on the collection and the other operates on the boolean property. Whenever I modify the boolean property, the converter's Convert method is called, where as the same is not called if I modify the observable collection. What am I missing?? Snippets for your reference, xaml snipet, <Window.Resources> <local:WrapPanelWidthConverter x:Key="WrapPanelWidthConverter" /> <local:StateToColorConverter x:Key="StateToColorConverter" /> </Window.Resources> <StackPanel> <ListBox x:Name="NamesListBox" ItemsSource="{Binding Path=Names}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel x:Name="ItemWrapPanel" Width="500" Background="Gray"> <WrapPanel.RenderTransform> <TranslateTransform x:Name="WrapPanelTranslatation" X="0" /> </WrapPanel.RenderTransform> <WrapPanel.Triggers> <EventTrigger RoutedEvent="WrapPanel.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="WrapPanelTranslatation" Storyboard.TargetProperty="X" To="{Binding Path=Names,Converter={StaticResource WrapPanelWidthConverter}}" From="525" Duration="0:0:2" RepeatBehavior="100" /> </Storyboard> </BeginStoryboard> </EventTrigger> </WrapPanel.Triggers> </WrapPanel> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Label Content="{Binding}" Width="50" Background="LightGray" /> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Button Content="{Binding Path=State}" Background="{Binding Path=State, Converter={StaticResource StateToColorConverter}}" Width="100" Height="100" Click="Button_Click" /> </StackPanel> code behind snippet public class WrapPanelWidthConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ObservableCollection<string> aNames = value as ObservableCollection<string>; return -(aNames.Count * 50); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } public class StateToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool aState = (bool)value; if (aState) return Brushes.Green; else return Brushes.Red; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }

    Read the article

  • wpf prevent second click button

    - by neki
    hi! i have a problem again. when i click button, window appears. when i click button again same window appears again. i want when i click button first time, page appears. but i wanna prevent second click. can anyone help me about this problem? thanks in advance. private void Dictionary_Click(object sender, RoutedEventArgs e) { Dictionary dic = new Dictionary(); dic.Show(); dic.Topmost = true; }

    Read the article

  • WPF Combobox binding Question

    - by ebattulga
    I have a 2 Table. Product ProductName CategoryID Category ID CategoryName I'm filling combobox to table named 'category'. Code Product currentProduct=datacontext.products.FirstOrDefault(); this.datacontext=currentProduct; combobox1.Itemssource=datacontext.categories; XAML <Textbox Text="{Binding Path=ProductName}"></Textbox> <Combobox x:Name="combobox1" SelectedItem="Binding Path=CategoryID"></Combobox> When click save button, I'm doing datacontext.SubmitChanges() ProductName changed. But CategoryID not changed. My target is when i select from combobox, selected category ID set to CategoryID of currentProduct. (like currentProduct.CategoryID=(Category as combobox1.SelectedItem).ID) How to do is from xaml?

    Read the article

  • WPF: UnauthorizedAccessException using anonymous methods.

    - by Diego Pacheco Pedemonte
    Here is the thing, I want to create a simply app that copy many files from one site, and move them to another; but using async methods and create a new thread. private void button3_Click(object sender, RoutedEventArgs e) { //progressBar1.Maximum = _FileInfoArray.Count; DispatcherTimer dt1 = new DispatcherTimer(); foreach (FileInfo Fi in _FileInfoArray) { Thread t = new Thread(new ThreadStart(delegate() { DispatcherOperation _dispOp = progressBar1.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(delegate() { File.Copy(txtdestino.Text, Fi.FullName, true); //progressBar1.Value = n; //txtstatus.Content = ("Copiados " + n.ToString() + " archivos"); //Thread.Sleep(100); } )); _dispOp.Completed += new EventHandler(_dispOp_Completed); } )); t.Start(); } } UnauthorizedAccessException is throw! It says that I can't access to txtdestino content. Some clues? -------------------------------------------------------------------------------Edited This is the version with all the changes, get the same error :( any clues? private void button4_Click(object sender, RoutedEventArgs e) { //First: Build mynames List<string> mynames = new List<string>(); foreach (FileInfo fi in _FileInfoArray) { mynames.Add(fi.FullName); } Thread t = new Thread(new ThreadStart(delegate() { foreach (string fullname in mynames) { DispatcherOperation _dispOp = progressBar1.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(delegate() { string destino = System.IO.Path.Combine(@"C:\", System.IO.Path.GetFileName(fullname)); File.Copy(fullname, destino, true); //Some progressbar changes } )); _dispOp.Completed += new EventHandler(_dispOp_Completed); } } )); t.Start(); } File.Copy(txtdestino.Text, Fi.FullName, true); // here the exception is throw

    Read the article

  • WPF: Get Property that a control is Bound to in code behind

    - by Richard
    Hi all, I am trying to find a way to get the Property to which a control is bound (in c#). If I have the following: <dxe:ComboBoxEdit DisplayMember="Name" ItemsSource="{Binding Path=NameOptions, Mode=OneTime}" SelectedItem="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" /> I am now trying to get the location to which the SelectedItem is bound to, i.e. the result should be "Name". Then in code I need to do some stuff with that ViewModel Property. Issue is that I can't just hard code this as it is a generic method that needs to work with each control on the form. Thanks, Richard

    Read the article

  • Two Way Data Binding With a Object in WPF,Image Control

    - by Candy
    Sorry, my English is not very good, I have a object "Stuffs" "Stuffs" have a Property “Icon” now: xaml <Button Click="Button_Click"><Image Width="80" Height="80" Source="{Binding Path=Icon,Converter={StaticResource ImageConverter}}"/></Button> cs private void Button_Click(object sender, RoutedEventArgs e) { IconFloder.Title = "Icon"; String IconFloderPath = AppDomain.CurrentDomain.BaseDirectory + ItemIconFloder; if (!System.IO.Directory.Exists(IconFloderPath)) System.IO.Directory.CreateDirectory(IconFloderPath); IconFloder.InitialDirectory = IconFloderPath; IconFloder.Filter = "Image File|*.jpeg"; IconFloder.ValidateNames = true; IconFloder.CheckPathExists = true; IconFloder.CheckFileExists = true; if (IconFloder.ShowDialog() == true) { HideImage.Text = ItemIconFloder + "\\" + IconFloder.SafeFileName; ((sender as Button).Content as Image).Source = new ImageConverter().Convert(ItemIconFloder + "\\" + IconFloder.SafeFileName, Type.GetType("System.Windows.Media.ImageSource"), null, new System.Globalization.CultureInfo("en-US")) as ImageSource; } } class ImageConverter:IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string&&!String.IsNullOrEmpty(value.ToString())) { try { return new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + value)); } catch { } } return null; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } I would like to click buttons, change the picture, Also change Data Binding Stuffs.Icon But failed,I have no idea?I need help? I do not know whether I speak clearly

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >