Search Results

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

Page 52/239 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Calling a WPF Application and modify exposed properties?

    - by Justin
    I have a WPF Keyboard Application, it is developed in such a way that an application could call it and modify its properties to adapt the Keyboard to do what it needs to. Right now I have a file *.Keys.Set which tells the application (on open) to style itself according to that new style. I know this file could be passed as a command line argument into the application. That would not be a problem. My concern is, is there a way via a managed environment to change the properties of the executable as long as they are exposed properly, an example: 'Creates a new instance of the Keyboard Application Dim e_key as new WpfApplication("C:\egt\components\keyboard.exe") 'Sets the style path e_key.SetStylePath("c:\users\joe\apps\me\default.keys.set") e_key.Refresh() 'Applies the style e_key.HideMenu() 'Hides the menu e_key.ShowDeck("PIN") 'Shows the custom "deck" of keyboard keys the developer 'Created in the style application. ''work with events and response 'Clear the instance from memory e_key.close e_key.dispose e_key = nothing This would allow my application to become easily accessible to other Touch Screen Application Developers, allowing them to use my keyboard and keep the functionality they need. It seems like it might be possible because (name of executable).application shows all the exposed functions, properties, and values. I just have never done this before. Any help would be appreciated, thank you in advance.

    Read the article

  • Focus-dependent text change for TextBoxes in WPF

    - by Simon
    Hey there. I'm writing an application in WPF using the MVVM-pattern and will really often use TextBoxes. I don't want to use labels for the user to know user what the text box is for, i.e. I don't want something like this: <TextBlock> Name: </TextBlock> <TextBox /> Instead, I would like the TextBox to contain its own label. Statically, you would express it like this: <TextBox>Name</TextBox> If the cursor is displayed in the textbox, i.e. the TextBox gains focus, I want the description text to disappear. If the TextBox is left empty and it loses the focus, the description text should be shown again. It's similar to the search textbox of StackOverflow or the one of Firefox. (please tell me if your not sure what I mean). One TextBox's label may change at runtime, dependending on e.g. a ComboBox's selected element or a value in my ViewModel. (It's like in Firefox's search TextBox, if you select google from the search engins' menu, the TextBox's label changes to "Google", if you select "Yahoo" its set to "Yahoo"). Thus I want to be able to bind the label's content. Consider that I may already have a Binding on the Text-Property of the TextBox. How can implement such a behaviour and make it reusable for any of my TextBox's? Code is welcome but not needed; a description of what to do is enough. Thank you in advance.

    Read the article

  • Inline text box labels with WPF

    - by Douglas
    I'm trying to reproduce the layout of some paper forms in a WPF application. Labels for text boxes are to be "inline" with the content of the text boxes, rather than "outside" like normal Windows forms. So, with an Xxxxxx label: +-----------------------------+ | Xxxxxx: some text written | | in the multiline input. | | | | another paragraph continues | | without indentation. | | | | | +-----------------------------+ The Xxxxxx cannot be editable, if the user selects all the content of the text box, the label must remain unselected, I need to be able to style the text colour/formatting of the label separately, when there is no text in the text box, but it has focus, the caret should flash just after the label, and I need the baselines of the text in the text box and the label to line up. One solution I tried was putting a textblock partially over the input, then using text indent to indent the editable text, though this caused problems with following paragraphs, since they were indented too. I'm not sure how to indent just the first paragraph. It required some fiddling to get the text to line up - a more reliable setup would be ideal. So, any suggestions on how to set this up? Thanks

    Read the article

  • WPF C# Client/Server announcement system

    - by manemawanna
    I'm currently in the process of creating an announcement system at my place of work. The role of this system will be to replace all users email due to people misusing it and generally abusing the facility. The system will consist of: Web Portal: Will allow staff to enter any important announcements (this will be restricted via AD). SQL Server 2k5 DB: Will hold the announcements along with records of staff members and if they've read the announcements etc. Front End: Created in WPF & C# which is nearly complete, it will display the announcements to the users. Web Page: Client will contact every so often, which will return an xml file for the client to read. However my boss has now shifted the goal posts and would like the announcements to appear to the user once they are written to the database, rather than waiting on the client to contact the webpage. So now I'm a bit unsure as to how to go about this. I have one idea where I would create a small server application to monitor for new announcements then contact the clients to inform them to approach the website for the information they need. But I'm just looking to see if theres a better or more efficient way to do this or if someone else has a more appropriate idea or suggestion.

    Read the article

  • Grouping Categorized Data In WPF.

    - by VoidDweller
    Here is what I am trying to do. Dynamic Category: Columns can be 0 or more. Must contain 1 or more Type Columns. Will only be displayed if any row contains Type Column data associated with it. Data Rows: Will be added Asynchronously. Will be grouped by a Common Category column. Will add a Dynamic Category if it does not yet exist. Will add a Type Column if it does not yet exist within its appropriate Dynamic Category. Platform Info: WPF .Net 3.5 sp1 C# MVVM I have a few partially functional prototypes, but each has it's own major set of problems. Can any of you give me some guidance on this? Envision this nicely styled. :-) -------------------------------------------------------------------------- |[ Common Category ]|[ Dynamic Category 0 ]|[ Dynamic Category N ]| -------------------------------------------------------------------------- |[Header 1]|[Header 2]|[ Type 0 ]|[ Type N ]|[ Type 0 ]|[ Type N ]| -------------------------------------------------------------------------- |[Data 2 Group] | -------------------------------------------------------------------------- | Data A | Data 2 || Null | Data 1 || Data 0 | Data 1 || | Data B | Data 2 || Data 0 | Null || Data 0 | Data 1 || -------------------------------------------------------------------------- |[Data 1 Group] | -------------------------------------------------------------------------- | Data C | Data 1 || Null | Data 1 || Data 0 | Data 1 || | Data D | Data 1 || Null | Null || Data 0 | Null || -------------------------------------------------------------------------- Edit: Sorting and Paging is not necessary. I have looked at nested ListViews and DataGrids, dynamically building a Grid. Dynamically building a Grid and leveraging the SharedSizeGroup property seems the most promising strategy, but I am concerned about performance. Would a better approach be to consider this a dynamic report? If so, what should I be looking at? Thanks for your help.

    Read the article

  • [WPF] ExceptionValidationRule doesn't react to exceptions...

    - by Darmak
    Hi, I have an ExceptionValidationRule on my TextBox: <Window.Resources> <Style x:Key="textStyleTextBox" TargetType="TextBox"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" /> </Trigger> </Style.Triggers> </Style> </Window.Resources> <TextBox x:Name="myTextBox" {Binding Path=MyProperty, ValidatesOnExceptions=True}" Style="{StaticResource ResourceKey=textStyleTextBox}" /> and MyProperty looks like that: private int myProperty; public int MyProperty { get { return myProperty; } set { if(value > 10) throw new ArgumentException("LOL that's an error"); myProperty = value; } } In DEBUG mode, application crashes with unhandled exception "LOL that's an error" (WPF Binding Engine doesn't catch this and I think it should...). In RELEASE mode, everything works fine. Can someone tell me, why the hell is this happening? And how can I fix this?

    Read the article

  • WPF & Linq To SQL binding ComboBox to foreign key

    - by ZeroDelta
    I'm having trouble binding a ComboBox to a foreign key in WPF using Linq To SQL. It works fine when displaying records, but if I change the selection on the ComboBox, that change does not seem to affect the property to which it is bound. My SQL Server Compact file has three tables: Players (PK is PlayerID), Events (PK is EventID), and Matches (PK is MatchID). Matches has FKs for the the other two, so that a match is associated with a player and an event. My window for editing a match uses a ComboBox to select the Event, and the ItemsSource is set to the result of a LINQ query to pull all of the Events. And of course the user should be able to select the Event based on EventName, not EventID. Here's the XAML: <ComboBox x:Name="cboEvent" DisplayMemberPath="EventName" SelectedValuePath="EventID" SelectedValue="{Binding Path=EventID, UpdateSourceTrigger=PropertyChanged}" /> And some code-behind from the Loaded event handler: var evt = from ev in db.Events orderby ev.EventName select ev; cboEvent.ItemsSource = evt.ToList(); var mtch = from m in db.Matches where m.PlayerID == ((Player)playerView.CurrentItem).PlayerID select m; matchView = (CollectionView)CollectionViewSource.GetDefaultView(mtch); this.DataContext = matchView; When displaying matches, this works fine--I can navigate from one match to the next and the EventName is shown correctly. However, if I select a new Event via this ComboBox, the CurrentItem of the CollectionView doesn't seem to change. I feel like I'm missing something stupid! Note: the Player is selected via a ListBox, and that selection filters the matches displayed--this seems to be working fine, so I didn't include that code. That is the reason for the "PlayerID" reference in the LINQ query

    Read the article

  • Userdefined margins in WPF printing

    - by MTR
    Most printing samples for WPF go like this: PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { StackPanel myPanel = new StackPanel(); myPanel.Margin = new Thickness(15); Image myImage = new Image(); myImage.Width = dialog.PrintableAreaWidth; myImage.Stretch = Stretch.Uniform; myImage.Source = new BitmapImage(new Uri("pack://application:,,,/Images/picture.bmp")); myPanel.Children.Add(myImage); myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight)); myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize)); dialog.PrintVisual(myPanel, "A Great Image."); } What I don't like about this is, that they always set the margin to a fixed value. But in PrintDialog the user has the option to choose a individual margin that no sample cares about. If the user now selects a margin that is larger as the fixed margin set by program, the printout is truncated. Is there a way to get the user selected margin value from PrintDialog? TIA Michael

    Read the article

  • WPF Prism's delegatecommand not refreshing

    - by gkar
    I am building wpf edit form, that has two buttons, BeginEdit and Save And the form is bound to ViewModel that inherits from Prism's NotificationObject. There is a property called IsReadOnly And there are two commands that are Prism's DelegateCommands BeginEdit command and save command The code is here private DelegateCommand _beginEdit; public DelegateCommand BeginEdit { get { return _beginEdit ?? (_beginEdit = new DelegateCommand(() => this.IsReadOnly = false , () => IsReadOnly)); } } private bool _isReadOnly; public bool IsReadOnly { get { return _isReadOnly; } set { _isReadOnly = value; RaisePropertyChanged("IsReadOnly"); } } private DelegateCommand _saveEdit; public DelegateCommand SaveEdit { get { return _saveEdit ?? (_saveEdit = new DelegateCommand(() => this.IsReadOnly = true , () => !IsReadOnly)); } } So, as you see, the command will set IsReadOnly property to true or false, and CanExecute should get its value from the same property as well. It works when I start the form. But after I press BeginEdit, the buttons stays as the same, and the canExecute is not reflecting the new value of IsReadOnly

    Read the article

  • WPF/Silverlight Resources for Businesses

    - by Refracted Paladin
    I am the only developer at a non-profit organization(~200 employees) where we are a M$ shop and 90% of the things I develop are specific to our company and are internal only. I am given a lot of latitude on how I accomplish my goals so using new technologies is in my best interest. So far I have developed all winform & asp.net applications. I would now like to focus on XAML driven development(WPF & Silverlight) and would like your help. I am subscribed to numerous Silverlight blogs and I have went through a few good tutorials however, I would really appreciate a GOOD SOLID book in my hands going forward. I prefer learning books versus reference books and I REALLY would like one from a Business standpoint as well. Shameless, self-promoting is welcomed if you happen to be an author or reviewer for one that meets my criteria. I would, however, prefer that recomendations were based on first-hand experience(no, 'my friend as this awesome book he told me about', please). Though, I don't mind un-released books if say they are an updated version of an existing. If more info is needed to provide accurate recomendations please let me know. Thanks disclaimer -- I know there are an insane amount of Book posts here(SO) but none I believe for my specific need. If there is and I missed it I apologize.

    Read the article

  • WPF app startup problems

    - by Dave
    My brain is all over the map trying to fully understand Unity right now. So I decided to just dive in and start adding it in a branch to see where it takes me. Surprisingly enough (or maybe not), I am stuck just getting my darn Application to load properly. It seems like the right way to do this is to override OnStartup in App.cs. I've removed my StartupUri from App.xaml so it doesn't create my GUI XAML. My App.cs now looks something like this: public partial class App : Application { private IUnityContainer container { get; set; } protected override void OnStartup(StartupEventArgs e) { container = new UnityContainer(); GUI gui = new GUI(); gui.Show(); } protected override void OnExit(ExitEventArgs e) { container.Dispose(); base.OnExit(e); } } The problem is that nothing happens when I start the app! I put a breakpoint at the container assignment, and it never gets hit. What am I missing? App.xaml is currently set to ApplicationDefinition, but I'd expect this to work because some sample Unity + WPF code I'm looking at (from Codeplex) does the exact same thing, except that it works! I've also started the app by single-stepping, and it eventually hits the first line in App.xaml. When I step into this line, that's when the app just starts "running", but I don't see anything (and my breakpoint isn't hit). If I do the exact same thing in the sample application, stepping into App.xaml puts me right into OnStartup, which is what I'd expect to happen. Argh! Is it a Bad Thing to just put the Unity construction in my GUI's Window_Loaded event handler? Does it really need to be at the App level?

    Read the article

  • Calling a WPF Appliaction and modify exposed properties?

    - by Justin
    I have a WPF Keyboard Application, it is developed in such a way that an application could call it and modify its properties to adapt the Keyboard to do what it needs to. Right now I have a file *.Keys.Set which tells the appliaction (on open) to style itself according to that new style. I know this file could be passed as a command line argument into the appliaction. That would not be a problem. My concern is, is thier a way via a managed environment to change the properties of the executable as long as they are exposed properly, an example: 'Creates a new instance of the Keyboard Appliaction Dim e_key as new WpfAppliaction("C:\egt\components\keyboard.exe") 'Sets the style path e_key.SetStylePath("c:\users\joe\apps\me\default.keys.set") e_key.Refresh() 'Applies the style e_key.HideMenu() 'Hides the menu e_key.ShowDeck("PIN") 'Shows the custom "deck" of keyboard keys the developer 'Created in the style appliaction. ''work with events and resposne 'Clear the instance from memory e_key.close e_key.dispose e_key = nothing This would allow my application to become easily accessible to other Touch Screen Application Developers, allowing them to use my key_board and keep the functionality they need. It seems like it might be possible because (name of executable).application shows all the exposed functions, properties, and values. I just have never done this before. Any help would be appreciated, thank you in advance.

    Read the article

  • WPF Event Handler in Another Class

    - by Nathan Tornquist
    I have built a series of event handlers for some custom WPF controls. The event handles format the text displayed when the user enters or leaves a textbox based on the type of data contained (Phone number, zip code, monetary value, etc.) Right now I have all of the events locally in the C# code directly attached to the xaml. Because I have developed a could controls, this means that the logic is repeated a lot, and if I want to change the program-wide functionality I would have to make changes everywhere the event code is located. I am sure there is a way to put all of my event handlers in a single class. Can anyone help point me in the correct direction? I saw this article: Event Handler located in different class than MainWindow But I'm not sure if it directly relates to what I'm doing. I would rather make small changes to the existing logic that I have, as it works, then rewrite everything into commands. I would essentially like to something like this if possible: LostFocus="ExpandedTextBoxEvents.TextBox_LostFocus" It is easy enough to do something like this: private void TextBoxCurrencyGotFocus(object sender, RoutedEventArgs e) { ExpandedTextBoxEvents.TextBoxCurrencyGotFocus(sender, e); } private void TextBoxCurrencyLostFocus(object sender, RoutedEventArgs e) { ExpandedTextBoxEvents.TextBoxCurrencyLostFocus(sender, e); } But that is less elegant.

    Read the article

  • How to refactor models without breaking WPF views?

    - by Tim Murphy
    I've just started learning WPF and like the power of databinding it presents; that is ignoring the complexity and confusion for a noob. My concern is how do you safely refactor your models/viewmodels without breaking the views that use them? Take the following snippet of a view for example: <Grid> <ListView ItemsSource="{Binding Contacts}"> <ListView.View> <GridView> <GridViewColumn Header="First Name" DisplayMemberBinding="{Binding Path=FirstName}"/> <GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding Path=FirstName}"/> <GridViewColumn Header="DOB" DisplayMemberBinding="{Binding Path=DateOfBirth}"/> <GridViewColumn Header="# Pets" DisplayMemberBinding="{Binding Path=NumberOfPets}"/> <GridViewColumn Header="Male" DisplayMemberBinding="{Binding Path=IsMale}"/> </GridView> </ListView.View> </ListView> </Grid> The list is bound to the Contacts property, IList(Of Contact), of the windows DataSource and each of the properties for a Contact is bound to a GridViewColumn. Now if I change the name of the NumberOfPets property in the Contact model to PetCount the view will break. How do I prevent the view breaking?

    Read the article

  • Bind to a collection's view and just call ToString() in WPF

    - by womp
    I'm binding a GridView to a collection of objects that look like this: public class Transaction { public string PersonName { get; set; } public DateTime TransactionDate { get; set; } public MoneyCollection TransactedMoney { get; set;} } MoneyCollection simply inherits from ObservableCollection<T>, and is a collection of MyMoney type object. In my GridView, I just want to bind a column to the MoneyCollection's ToString() method. However, binding it directly to the TransactedMoney property makes every entry display the text "(Collection)", and the ToString() method is never called. Note that I do not want to bind to the items in MoneyCollection, I want to bind directly to the property itself and just call ToString() on it. I understand that it is binding to the collection's default view. So my question is - how can I make it bind to the collection in such a way that it calls the ToString() method on it? This is my first WPF project, so I know this might be a bit noobish, but pointers would be very welcome.

    Read the article

  • Unit testing a 'legacy' WPF Application

    - by sc_ray
    The product I have been working on has been in development for the past six years. It started as a generic data entry portal into an insanely complex part WPF/part legacy application. The system has been developed for all these years without a single Unit test in its fold. Now, the point has been raised for a comprehensive unit testing framework. I have been recruited recently to work on this product and have been tasked to get the 'Testing' in order. Since the team that worked on the product for the last six years adopted 'Agile', the project lacks any documentation of the business rules or any design documents. I have been trying to write unit tests for some of the modules. But I am not sure what to Mock, how to setup my Test fixture and eventually what to Test for, since a casual glance of the methods does not reveal its intentions. Also, it has come to my attention that the code was not developed with a particular methodology in mind. Given the situation, I was wondering if the good people of Stackoverflow could provide me with some advise on how to salvage this situation. I have heard about the book 'Working with Legacy Code' that has something to say about this general situation but I was thinking about getting some pointers from individuals who have encountered similar situations within the technology stack(C#,VB,C++,.NET 3.5,WCF,SQL Server 2005).

    Read the article

  • Problem Binding to a Brush Property in WPF

    - by Krisc
    Working in WPF, writing a custom user control. I am trying to change the background property of the Border element when I change the value of a property of the class. Right now I am working on simply binding it to a DP, though if there is a better way I am open to suggestions. Here is the XAML for the UserControl <UserControl x:Class="MyProject.MyControl" 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" xmlns:js="clr-namespace:MyProject" mc:Ignorable="d" x:Name="MyControlRootLayout" Background="Transparent" d:DesignHeight="300" d:DesignWidth="300" Cursor="Hand"> <Border x:Name="RootBorder" Background="{Binding Path=CoreBackground, ElementName=MyControlRootLayout}" > </Border> </UserControl> And the code... public partial class MyControl : UserControl { public static DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(MyControl)); public static DependencyProperty CoreBackgroundProperty = DependencyProperty.Register("CoreBackground", typeof(Brush), typeof(MyControl)); public MyControl() { CoreBackground = new SolidColorBrush(Color.FromArgb(0, 255, 245, 104)); InitializeComponent(); Margin = new Thickness(5); } public Brush CoreBackground { get { return (Brush)GetValue(CoreBackgroundProperty); } set { SetValue(CoreBackgroundProperty, value); } } public bool IsSelected { get { return (bool)GetValue(IsSelectedProperty); } private set { SetValue(IsSelectedProperty, value); } } } Instead, the background comes out as transparent.

    Read the article

  • Firing PropertyChanged event in a complex, nested type in WPF

    - by John
    Hey I have a question about the PropertyChanged vent firing in WPF whne it is used in a complex type. I have a class called DataStore and a list of Departments (an ObservableCollection), and each department again has a list of Products. Properties in the Product class that are changed also affect properties in the Department and DataStore class. How does each Product notify the Department it belongs to, and the DataStore (which is the mother class of all) that one or more of its properties have changed their values? Example: a product has a property NumberSoldToday and is bound. The Department has a property called TotalNumberOfProductsSold: public int TotalNumberOfProductsSold { get { int result = 0; foreach(Product p in this.products) result += p.NumberSoldToday; return result; } } And the data store has a property TotalProductsSold (for all departments): public int TotalProductsSold { get { int result = 0; foreach(Product p in this.deparments) result += p.TotalNumberOfProductsSold; return result; } } If all these properties are bound, and the innermost property changes, it must somehow notify that the value of the other 2 changed as well. How? The only way I can see this happening is to hook up the PropertyChanged event in each class. Th event must also fire when deleting, adding to the collection of products and deparments, respectively. Is there a better, more clever way to do this?

    Read the article

  • Strange behaviour when collapsing lines in XML bound WPF Datagrid

    - by Flossn
    i am using a wpf datagrid with a xml file as DataContext. All working good except for iterating thorough the table and collapsing individual rows. There are several checkboxes where the user can decide which kinds of rows he wants to see, dependent on their error level string. If a checkbox is checked, some of the rows are collapsed, others not. You need to uncheck the checkbox and check it again to collapse the ones of the first try and some of the others. If you recheck it again more rows are collapsed every time. I guess it has something to do with how much of the list is actually visible and how much not because of the window size. Thanks in advance. foreach (DataGridRow r in rows) { bool showRow = true; var tb = Datagrid.GetCell(dataGridEvents, r, 2).Content; string level = ((TextBlock)tb).Text; switch (level) { case "Warning": showRow = checkBoxWarnings.IsChecked.HasValue ? checkBoxWarnings.IsChecked.Value : false; break; case "Critical": showRow = checkBoxCritical.IsChecked.HasValue ? checkBoxCritical.IsChecked.Value : false; break; case "OK": showRow = checkBoxOK.IsChecked.HasValue ? checkBoxOK.IsChecked.Value : false; break; case "Unknown": showRow = checkBoxUnknown.IsChecked.HasValue ? checkBoxUnknown.IsChecked.Value : false; break; } r.Visibility = showRow ? Visibility.Visible : Visibility.Collapsed; }

    Read the article

  • WPF binding problem

    - by Lolo
    I've got problem with binding in XAML/WPF. I created Action class witch extends FrameworkElement. Each Action has list of ActionItem. The problem is that the Data/DataContext properties of ActionItem are not set, so they are always null. XAML: <my:Action DataContext="{Binding}"> <my:Action.Items> <my:ActionItem DataContext="{Binding}" Data="{Binding}" /> </my:Action.Items> </my:Action> C#: public class Action : FrameworkElement { public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register("Items", typeof(IList), typeof(Action), new PropertyMetadata(null, null), null); public Action() { this.Items = new ArrayList(); this.DataContextChanged += (s, e) => MessageBox.Show("Action.DataContext"); } public IList Items { get { return (IList)this.GetValue(ItemsProperty); } set { this.SetValue(ItemsProperty, value); } } } public class ActionItem : FrameworkElement { public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(object), typeof(ActionItem), new PropertyMetadata( null, null, (d, v) => { if (v != null) MessageBox.Show("ActionItem.Data is not null"); return v; } ), null ); public object Data { get { return this.GetValue(DataProperty); } set { this.SetValue(DataProperty, value); } } public ActionItem() { this.DataContextChanged += (s, e) => MessageBox.Show("ActionItem.DataContext"); } } Any ideas?

    Read the article

  • WPF Databinding With A Collection Object

    - by Randster
    Argh, although I've been googling, I really would appreciate it if someone could break my problem down as all the code examples online are confusing me more than assisting (perhaps it's just late)... I have a simple class as defined below: public class Person { int _id; string _name; public Person() { } public int ID { get { return _id; } set { _id = value; } } public string Name { get { return _name; } set { _name = value; } } } that is stored in a database, and thru a bit more code I put it into an ObservableCollection object to attempt to databind in WPF later on: public class People : ObservableCollection<Person> { public People() : base() { } public void Add(List<Person> pListOfPeople) { foreach (Person p in pListOfPeople) this.Add(p); } } In XAML, I have myself a ListView that I would like to populate a ListViewItem (consisting of a textblock) for each item in the "People" object as it gets updated from the database. I would also like that textblock to bind to the "Name" property of the Person object. I thought at first that I could do this: lstPeople.DataContext = objPeople; where lstPeople is my ListView control in my XAML, but that of course does nothing. I've found TONS of examples online where people through XAML create an object and then bind to it through their XAML; but not one where we bind to an instantiated object and re-draw accordingly. Could someone please give me a few pointers on: A) How to bind a ListView control to my instantiated "People" collection object? B) How might I apply a template to my ListView to format it for the objects in the collection? Even links to a decent example (not one operating on an object declared in XAML please) would be appreciated. Thanks for your time.

    Read the article

  • C# WPF Show Image from Mysql

    - by user3718026
    i'm a student and i am bad at programing. I saved the images in my mysql database for each player. I created a program where I can list some soccer players from my database. When i click on a listed player in datagrid, a new window appears with the information about the player. Everything works, but now i want a picture of the selected player to be displayed on the information window from the database. Can anybody help me? My english is not the best (i'm 17) so i hope you can understand what i mean. This is what i tried to do but i don't know how to continue. PS. It's in WPF. MySqlCommand cmd = new MySqlCommand("SELECT Bilder FROM spieler WHERE Bilder='{8}'"); MySqlDataReader rdr1 = cmd.ExecuteReader(); try { conn.Open(); while (rdr1.Read()) { // image1... I don't know what to write here } } catch (Exception ex) { MessageBox.Show("Fehler: " + ex); } rdr1.Close()

    Read the article

  • How to customize file dialog in wpf

    - by ManjuAnoop
    In Windows7 I am using a customized Open File Dialog( WPF application). My Open File dialog is derived from Microsoft.Win32.CommonDialog. The dialog have old look, how to change this to new look (windows7 file dialog look(Explorer style)). Code portion: private const int OFN_ENABLESIZING = 0x00800000; private const int OFN_EXPLORER = 0x00080000; private const int OFN_ENABLEHOOK = 0x00000020; protected override bool RunDialog(IntPtr hwndOwner) { OPENFILENAME_I.WndProc proc = new OPENFILENAME_I.WndProc(this.HookProc); OPENFILENAME_I ofn = new OPENFILENAME_I(); this._charBuffer = CharBuffer.CreateBuffer(0x2000); if (this._fileNames != null) { this._charBuffer.PutString(this._fileNames[0]); } ofn.lStructSize = Marshal.SizeOf(typeof(OPENFILENAME_I)); ofn.hwndOwner = hwndOwner; ofn.hInstance = IntPtr.Zero; ofn.lpstrFilter = MakeFilterString(this._filter, this.DereferenceLinks); ofn.nFilterIndex = this._filterIndex; ofn.lpstrFile = this._charBuffer.AllocCoTaskMem(); ofn.nMaxFile = this._charBuffer.Length; ofn.lpstrInitialDir = this._initialDirectory; ofn.lpstrTitle = this._title; ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_ENABLEHOOK; ofn.lpfnHook = proc; ofn.FlagsEx = 0x1000000 ; NativeMethods.GetOpenFileName(ofn); // } [SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("comdlg32.dll", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool GetOpenFileName([In, Out] OPENFILENAME_I ofn);

    Read the article

  • Some questions about focus on WPF

    - by ThitoO
    Hello, I've a little problem about focus on WPF. I whant to create a window, always on top, and that never get the focus (even if we click on it). Here's my solution : public partial class SkinWindow : Window { public SkinWindow() { InitializeComponent(); Loaded += ( object sender, RoutedEventArgs e ) => SetNoActiveWindow(); } private void SetNoActiveWindow() { WindowInteropHelper helper = new WindowInteropHelper( this ); SetWindowLong( helper.Handle, GWL_EXSTYLE, WS_EX_NOACTIVATE ); LockSetForegroundWindow( LSFW_LOCK ); } const int GWL_EXSTYLE = -20; const int WS_EX_NOACTIVATE = 134217728; const int LSFW_LOCK = 1; [DllImport( "user32" )] public static extern bool LockSetForegroundWindow( uint UINT ); [DllImport( "user32" )] public static extern IntPtr SetWindowLong( IntPtr hWnd, int nIndex, int dwNewLong ); } First problem : It's works, but I've to select an other window to "remove" the focus of my application (after the focus is not gave again, even if I click on my window). Second problem : When I move or resize the window, the modifications happens when I drop the window. Do you have any ideas / links / docs ? Thank you :)

    Read the article

  • Bind WPF control with property of custom type

    - by TheBlueSky
    Hello everyone, I'm trying to bind a Label's 'Content' property to a property from some custom type I have; unfortunately, I didn't figure out how to do it, and that's why I'm here :) Let's assume that I have the following type (can be in the same namespace as my WPF Window that contains the Label or different namespace): namespace MyNS { pubic class Person { private int age = 0; public int Age { get { return age; } } public void GetOlder { age++; } } } 1) How to I bind my Label to 'Age' property? 2) At runtime I will create an instance of 'Person'; I want to make sure that my Label is bound to the right instance; i.e. if I called: Person SomePerson = new Person(); SomePerson.GetOlder(); I want my Lable to have the new value of 'Age' property for 'SomePerson'. 3) If #2 was possible (I hope so), what if I called 'GetOlder' in different thread? Will I still get the latest value of 'Age'? Or do I have to take care of some other things as well to make this scenario possible? Thanks in advance, TheBlueSky

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >