Search Results

Search found 5961 results on 239 pages for 'wpf 4 5'.

Page 88/239 | < Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >

  • Activate WPF command based on TextBox value

    - by zendar
    This is MVVM application. I have form and related view model class. There is TextBox, Button and ListBox on form. Button is bound to DelegateCommand that has CanExecute function. Idea is that user enters some data in text box, presses button and data is appended to list box. I would like to enable command (and button) when user enters correct data in TextBox. Things look like this now: CanExecute() contains code that checks if data in property bound to text box is correct. Text box is bound to property in view model UpdateSourceTrigger is set to PropertyChanged and property in view model is updated after each key user presses. Problem is that CanExecute() does not fire when user enters data in text box. It doesn't fire even when text box lose focus. How could I make this work?

    Read the article

  • Bind event in custom WPF control to command in ViewModel

    - by Jon Archway
    Hi, I have a custom control that has an event. I have a window using that custom control. The window is bound to a viewmodel. I would like to have the event from the custom control direct to an ICommand on my viewmodel. I am obviously being dense here as I can't figure out how to do this. Any assistance is most welcome. Thanks

    Read the article

  • Have a clickable button on top of a combobox in WPF

    - by Travyguy9
    I can get a button to appear and be clickable in the drop down list of a combo box, but I cannot get the selected combo box item (the drop list is closed) to have the button be clickable. It always skips the button click and just opens the drop down list. I basically want the Button_Click event handler that I setup to be called once it is clicked. Here is my sample combo box that shows the button but is not clickable once it is in the selected item: <ComboBox x:Name="MyCombo" Width="200" Height="30" ItemsSource="{Binding ListCombo}"> <ComboBox.Resources> <DataTemplate DataType="{x:Type local:ComboItemClass}"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=SampleText}" Width="120" /> <Button Width="20" Content="..." Click="Button_Click"/> </StackPanel> </DataTemplate> </ComboBox.Resources> </ComboBox>

    Read the article

  • Applied style in WPF ignores properties.

    - by Quenton Jones
    Here's the conundrum. In two different places in my application, I use a border with the exact same appearance. In an never-ending fight against code bloat and unmanageable code, I want to define the border's appearance in a style to use when I create the border. Strangely, several of the properties I set are being ignored. Here's the code I use to create the style. Simple enough. Style borderStyle = new Style(typeof(Border)); borderStyle.Setters.Add(new Setter(Border.BorderBrushProperty, Brushes.Black)); borderStyle.Setters.Add(new Setter(Border.BorderThicknessProperty, new Thickness(4))); borderStyle.Setters.Add(new Setter(Border.OpacityProperty, 1.0)); return borderStyle; But when I set the style, the opacity property is left at its original value of 0.7. I have also tried setting the background of the border to a brush I created. It too is ignored. Thanks for any insights you may have.

    Read the article

  • How to create DataSource dependency property on a wpf User Control

    - by Michael Hedgpeth
    I have a user control that wraps a grid. I want to be able to set the underlying grid's data source, but through the user control, like this: <my:CustomGrid DataSource="{Binding Path=CollectionView}" /> I have set this up in the grid like this: private static readonly DependencyProperty DataSourceProperty = DependencyProperty.Register("DataSource", typeof(IEnumerable), typeof(CustomGrid)); public IEnumerable DataSource { get { return (IEnumerable)GetValue(DataSourceProperty); } set { SetValue(DataSourceProperty, value); underlyingGrid.DataSource = value; } } But this doesn't work (it doesn't give me an error either). The data source is never set. What am I missing?

    Read the article

  • WPF Binding Path=/ not working?

    - by Mark
    I've set up my DataContext like this: <Window.DataContext> <c:DownloadManager /> </Window.DataContext> Where DownloadManager is Enumerable<DownloadItem>. Then I set my DataGrid like this: <DataGrid Name="dataGrid1" ItemsSource="{Binding Path=/}" ... So that it should list all the DownloadItems, right? So I should be able to set my columns like: <DataGridTextColumn Binding="{Binding Path=Uri, Mode=OneWay}" Where Uri is a property of the DownloadItem. But it doesn't seem to like this. In the visual property editor, it doesn't recognize Uri is a valid property, so I'm guessing I'm doing something wrong. It was working before, when I had the data grid binding to Values, but then I took that enumerable out of the DownloadManager and made itself enumerable. How do I fix this? PS: By "doesn't work" I mean it doesn't list any items. I've added some to the constructor of the DM, so it shouldn't be empty.

    Read the article

  • WPF Creating an instance of a class in xaml

    - by Cloverness
    Hi, I have a problem with creating the instance of a class in xaml file. I thought you can do it like this: in the resource part of the user control and then use it in the xaml file (for example bind to it). But even tough the class I created is located in the same namespace it says that: "The type was not found. Verfiy that all assemblies were built, etc". How to get it right? is there another method? Thanks for suggestions.

    Read the article

  • Setting Icon for wpf application (VS 08)

    - by baron
    Hi everyone, Before going much further i'll mention I have tried solutions in following: http://stackoverflow.com/questions/320677/how-do-i-set-the-icon-for-my-application-in-visual-studio-2008 http://stackoverflow.com/questions/198848/set-application-icon-from-resources-in-vs-05 I am trying to set an icon for my application. AFAIK, I need potentially 3 images? 1 image is the actual image in explorer when clicking on the .exe (thumbnail for the exe) 1 image (tiny) in the top left corner (16 x 16? Not entirely sure) 1 image in the start menu dock, to the left of the app (maybe 32x32? again not sure) So thats fine. Now I have selected an Icon. How do I use it in one of above situations? I have tried adding it in resources, nothing seems to happen. Following that first SO solution, "First go to Resource View (from menu: View -- Other Window -- Resource View). Then in Resource View navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon." The resource view is empty, and I cannot right click in this view. If I right click on the solution properties resources I can add the icon image, but it doesn't show in either of the locations listed above. (or anywhere that I can see) What am I doing wrong?

    Read the article

  • WPF Converter to look up in generic list

    - by user310046
    I have a list of data where I keep e.g. countries with code, name and some other data. List<Country> countries = <deserialized objects from file> which consist of objects like this: public class Country { public string Code { get; set;} public string Name { get; set;} } The object which use as a DataContext may look like this: public class Address { public string StreetName{ get; set;} public string CountryCode { get; set;} } Then in my XAML I want to do something like this to show the name of the country <TextBlock Text="{Binding Path=CountryCode, Converter={StaticResource CountryNameLookupConverter}}"/> But how can I make the CountryNameLookupConverter use the countries list I read from the xml file?

    Read the article

  • Set the focus on a textbox in xaml wpf

    - by devnet247
    Hi dispite some posts on this forum and others i cannot find something that tells me how to set the focus on a text box. I have a userControl with many labels and textBoxes.When the form is loaded I want the a particular textBox to have the focus. I have set the tabIndex but that didnt seem to work. Any suggestions

    Read the article

  • WPF: ListBox click and drag selects other items

    - by Bodekaer
    Hi, Simple question: 1) I click and hold the mouse on a ListBoxItem in a ListBox. 2) Now I drag the mouse cursor down over the next ListBoxItem in the list It now selects this new item. I would like to disable this. So the user has to click an item to select it. Not just drag over it. I have Single selection turned on. Any ideas are greatly appreciated :)

    Read the article

  • Modifying WPF listbox items container when using groupstyle

    - by rulestein
    I have a listbox that is grouping the items with a GroupStyle. I would like add a control at the bottom of the stackpanel that holds all of the groups. This additional control needs to be part of the scrolling content so that the user would scroll to the bottom of the list to see the control. If I were using a listbox without the groups, this task would be easy by modifying the ListBox template. However, with the items grouped, the ListBox template seems to only apply on a per group basis. I can modify the GroupStyle.Panel, but that doesn't allow me to add items to that panel. <----- I would like to add a control to this stackpanel

    Read the article

  • WPF Databinding and Styling based on Data in an item in an IList

    - by Nate Bross
    I have a ListBox bound to a list of Items (for arguement, lets say its got a string and two dates Entered and Done). I would like to make the background color of items in the ListBox have a gray color if the Done DateTime is != DateTime.MinValue. Edit: Should I make a converter? and convert DateTime to a Brush based on the value of the DateTime? Is something like this my best option? or is there a simple Xaml snippet I could use? [ValueConversion(typeof(DateTime), typeof(Brush))] class MyConverter : IValueConverter { ... }

    Read the article

  • WPF: Can't get to original source from ExecutedRoutedEventArgs

    - by Ikhail
    I have a problem getting to the original source of a command using ExecutedRoutedEventArgs. I'm creating a simple splitbutton, in which a menu will appear below a dedicated button, as another button is pressed. When I click a menuitem in the appearing menu a command is fired. This command is registered on the splitbutton. And the idea is to get to the menuitem beeing clicked, by using the ExecutedRoutedEventsArgs. Ok, now the problem. If I choose to have the popup menu shown by default (IsOpen="True") and I click one of the menuitems I can get to the originalsource (thus the menuitem) from the ExecutedRoutedEventArgs - no problem. However, if I first click the button to show the menu and THEN click on a menuitem, the originalsource of the command will be the button instead of the MenuItem! Here's the controltemplate for the splitbutton: <ControlTemplate TargetType="{x:Type usc:SplitButton}"> <StackPanel Orientation="Horizontal"> <Button Name="mybutton"> <StackPanel> <Popup usc:SplitButton.IsPopup="True" IsOpen="True" Name="myPopup" PlacementTarget="{Binding ElementName=mybutton}" StaysOpen="False" Placement="Bottom"> <Border BorderBrush="Beige" BorderThickness="1"> <Menu Width="120"> <MenuItem Header="item1" Command="usc:SplitButton.MenuItemClickCommand" /> <MenuItem Header="item2" /> <MenuItem Header="item3" /> </Menu> </Border> </Popup> <TextBlock Text="MySplitbutton" /> </StackPanel> </Button> <Button Content="OK" Command="usc:SplitButton.ShowMenuCommand" /> </StackPanel> </ControlTemplate> The OK button fires a ShowMenuCommand on the SplitButton, which sets the IsOpen property on the Popup to True. Any ideas why the OK button (after having activated the menu) is the OriginalSource when a menuitem is clicked? Thanks.

    Read the article

  • WPF problem modify style of images in multiple Button Templates

    - by user556415
    I'm trying to create a control panel for a video camera, the panel has buttons for up, down, left and right etc. Each camera function up, down, left and right is represented by three images (see code below) for the left side, middle and right side. The control panel is circular so the corner images kind of overlap (its complicated to explain this without a visual). When I click on up for example I have to hide the initial three images (leftside, middle and right side) and display another three images for left , middle and right that indicate that the button is pressed. I am achieving this by having a grid inside a button template. The problem I have is that for the corner images for the control there are really four images that represent this. For example for the top left corner the four images would be represent 1. Top not clicked. 2. Top Clicked and 3. Left Not clicked and 4. Left Clicked. My problem is if I need to make the images contained within the Top button have precedence when the top control is clicked or the images in the left button have precedence when the left button is clicked. So it's like I want to modify the left button's image visible property when the top button is clicked and vise versa. This is really difficult to explain so I apologize if it makes little sense but I can email the source code on request if anyone is interested in my predicament. <Grid> <Canvas> <!--<StackPanel>--> <Button Name="TopSide" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height="34" Width="102" Canvas.Left="97" Canvas.Top="60" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid Width="100"> <Canvas> <Image Name="TopRightNormal" Source="Resources/topright_off.jpg" Height="34" Width="34" Canvas.Left="66"></Image> <Image Name="TopRightDown" Source="Resources/topright_down.jpg" Height="34" Width="34" Canvas.Left="66" Visibility="Hidden" ></Image> <Image Name="TopNormal" Source="Resources/topcenter_off.jpg" Height="34" Width="34" Canvas.Left="34" /> <Image Name="TopPressed" Source="Resources/topcenter_down.jpg" Height="34" Width="34" Canvas.Left="34" Visibility="Hidden" /> <Image Name="TopDisabled" Source="Resources/topcenter_off.jpg" Height="34" Width="34" Canvas.Left="34" Visibility="Hidden" /> <Image Name="TopLeftNormal" Source="Resources/topleft_off.jpg" Height="34" Width="34" Canvas.Left="2" ></Image> <Image Name="TopLeftDown" Opacity="0" Source="Resources/topleft_down.jpg" Height="34" Width="34" Canvas.Left="2" Visibility="Hidden" ></Image> </Canvas> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="TopNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopPressed" Property="Visibility" Value="Visible" /> <Setter TargetName="TopRightNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopRightDown" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopLeftDown" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftDown" Property="Opacity" Value="100" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="TopNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopDisabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <!--<StackPanel>--> <Button Name="LeftSide" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Canvas.Left="100" Canvas.Top="60" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MouseDown="Button_MouseDown_1"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid Width="34" Height="100"> <Canvas> <Image Name="TopLeftNormal" Source="Resources/topleft_off.jpg" Height="34" Width="34" Canvas.Left="0"></Image> <Image Name="TopLeftDown" Opacity="0" Source="Resources/topleft_leftdown.jpg" Height="34" Width="34" Canvas.Left="0" Visibility="Hidden" ></Image> <Image Name="Normal" Source="Resources/leftcenter_off.jpg" Height="34" Width="34" Canvas.Top="32" Canvas.Left="0"/> <Image Name="Pressed" Source="Resources/leftcenter_down.jpg" Visibility="Hidden" Canvas.Top="32" Height="34" Width="34" /> <Image Name="Disabled" Source="Resources/leftcenter_off.jpg" Visibility="Hidden" Height="34" Width="34" Canvas.Top="32" /> </Canvas> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Pressed" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopLeftNormal" Property="Opacity" Value="0" /> <Setter TargetName="TopLeftDown" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftDown" Property="Opacity" Value="100" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Disabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <!--<StackPanel>--> <Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height="34" Width="34" Canvas.Left="165" Canvas.Top="92" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MouseDown="Button_MouseDown_2" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Image Name="Normal" Source="Resources/rightcenter_off.jpg" /> <Image Name="Pressed" Source="Resources/rightcenter_down.jpg" Visibility="Hidden" /> <Image Name="Disabled" Source="Resources/rightcenter_off.jpg" Visibility="Hidden" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Pressed" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Disabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <!--<StackPanel>--> <Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height="34" Width="34" Canvas.Left="133" Canvas.Top="124" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Image Name="BottomNormal" Source="Resources/bottomcenter_off.jpg" /> <Image Name="BottomPressed" Source="Resources/bottomcenter_down.jpg" Visibility="Hidden" /> <Image Name="BottomDisabled" Source="Resources/bottomcenter_off.jpg" Visibility="Hidden" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="BottomNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="BottomPressed" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="BottomNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="BottomDisabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <Image Source="Resources/bottomright_off.jpg" Height="34" Width="34" Canvas.Left="165" Canvas.Top="124"></Image> <Image Source="Resources/bottomleft_off.jpg" Height="34" Width="34" Canvas.Left="100" Canvas.Top="124"></Image> <!--<ToggleButton Style="{StaticResource MyToggleButtonStyle}" Height="34" Width="34" Margin="150,100"/>--> </Canvas> </Grid>

    Read the article

  • Clip a 4:3 image in WPF with a circle

    - by reckoner
    I am trying to clip a 4:3 image with a circle within a grid control. I need the circle clip to reveal the image from the middle in a perfect circle. See below. The circle should dynamically re-size with the image. I have tried Canvas.Clip and Ellipse+VisualBrush without achieving the correct behavior. Thanks!

    Read the article

  • WPF Button on or off coloured state

    - by wonea
    I'm trying to create a set of button which have an off or on state, much a checkbox without the check. Ideally I want the colour to change to represent the two different states off(red), green(on). I've tried setting a control template but this only changes the colour for a selection, then reverts back to it's original colour once the mouse leaves the button's vicinity. <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background" TargetName="Background" Value="Green"/> </Trigger> </ControlTemplate.Triggers>

    Read the article

  • How to pass data between controls and persist the values in WPF

    - by randyc
    I am stuck on how to pass data from one control to another. If I have a listbox control and the Contol Item contains a datatemplate which renders out 5 fields ( first name, last name, email, phone and DOB) all of which come from an observable collection. How can I allow the user to select a listbox item and have the valuesbe stored within a new listbox control? Is this done through the creation of a new collection or is there a more simple way to bind these values to a new control? thank you,

    Read the article

  • WPF databind in memory image to Image control

    - by Ready Cent
    I am using a DataGrid and trying to do the following Databinding <DataTemplate> <Grid> <Image> <Image.Source> <BitmapImage UriSource="{Binding Data.CustomImage}" CacheOption="OnLoad" /> </Image.Source> </Image> </Grid> </DataTemplate> CustomImage is of type BitmapImage. When I run I get the error: Initialization of 'System.Windows.Media.Imaging.BitmapImage' threw an exception. The thing is that these images are stored as resources in a different assembly so I can't just point to a location on disk

    Read the article

  • WPF Custom Navigation Buttons and calling one page from another

    - by Jeff
    I have a window which contains a Frame which references a 'home' page that has buttons on it. When a button is clicked I want another page to show depending on which button was pressed. I attempted to use NavigationService.Navigate('mynextpage.xaml') and that works however, I want to use a customized navigation panel. I call this.ShowsNavigationUI = false; on my 'home' page but the bar still shows. Is there a way to accomplish what I am trying to do? My page with the frame is a window so I do not know how to disable the Navigation bar there where I guess it is coming from. Further testing shows that the ShowsNavigationUI property is false yet the nav bar shows itself in the parent window once there is a second page to go to (showing the 'home' page in the history. TIA

    Read the article

< Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >