Search Results

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

Page 28/239 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • wpf 4.0 datagrid template column two-way binding problem

    - by rouwlee
    Hello all! I'm using the datagrid from wpf 4.0. This has a TemplateColumn containing a checkbox. The IsChecked property of the checkbox is set via binding. The problem is that even if I specify the binding mode explicitly to be TwoWay, it works only in one direction. I have to mention that the same code works perfectly in .net 3.5 with the datagrid from the wpf toolkit. Please take a look at the .xaml and .cs contents. Thanks in advance, Roland <Window.Resources> <DataTemplate x:Key="IsSelectedColumnTemplate"> <CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" /> </DataTemplate> </Window.Resources> <Grid> <DataGrid x:Name="dataGrid" AutoGenerateColumns="false" CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility="Column" ItemsSource="{Binding}" > <DataGrid.Columns> <DataGridTemplateColumn Header="Preselected" x:Name="myIsSelectedColumn" CellTemplate="{StaticResource IsSelectedColumnTemplate}" CanUserSort="True" SortMemberPath="Orientation" Width="Auto" /> </DataGrid.Columns> </DataGrid> </Grid> and the related .cs content: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); ObservableCollection<DataObject> DataSource = new ObservableCollection<DataObject>(); DataSource.Add(new DataObject()); dataGrid.ItemsSource = DataSource; } } public class DataObject : DependencyObject { public bool IsSelected { get { return (bool)GetValue(IsSelectedProperty); } set { SetValue(IsSelectedProperty, value); } } // Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(DataObject), new UIPropertyMetadata(false, OnIsSelectedChanged)); private static void OnIsSelectedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { // this part is not reached } }

    Read the article

  • WPF touch and slide/drag animation

    - by George
    I'm trying to create a pretty simple WPF interface, and from what I know this should be mostly possible using pure XAML. What I know I have a pretty basic understanding of WPF so far, however I have a decent grasp on XAML. I know or can work out how to put content in these panels. This isn't the topic of this question. What I don't know I don't know how to animate this interface. I'm not very proficient at binding, however again, that's not the topic of this question. The topic of this question is what would be the best way to animate panels 1-4 (images below) so that they may be dragged (via touch) into view. The number of panels here may be static for the purpose of this question. The panels (1-4) can be stack panels, grids or whatever; their content isnt important. What is important is the container that would contain all 4 panels. The complication in this animation is the other two containers here (Item One/TODO), as they're in the way of a smooth animation. If it makes this question simpler, the touch features can be ignored for now, and a simple button push can slide the containers across. One Two

    Read the article

  • TextBlock Wrapping in WPF Layout

    - by Joel Martinez
    Hi, I'm trying to figure out how to do something similar to the twitter silverlight app that Scott Guthrie demoed recently in WPF: http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx Unfortunately, I seem to be having a hard time understanding the wpf layout system in some fundamental way. I've been trying various combinations of horizontalalignment/stretch, width/auto at different levels in the hierarchy, and I can't seem to get the "message" textblock to wrap without assigning an explicit width. All I want is for the text to wrap based on the width of the window (or whatever is the parent container). <Window x:Class="TweeterWin.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" Loaded="Window_Loaded"> <ScrollViewer Height="auto" > <ListBox Name="tweetList" Height="auto" > <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="132"> <Image Source="{Binding Avatar}" Height="73" Width="73" VerticalAlignment="Top" Margin="0,10,8,0"/> <StackPanel > <TextBlock Text="{Binding User}" TextWrapping="Wrap" Foreground="#FFC8AB14" FontSize="15" /> <TextBlock Text="{Binding Message}" TextWrapping="Wrap" FontSize="10" /> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </ScrollViewer> </Window> As a follow up, if anyone can send any links my way that might help me understand some of these layout fundamentals. I think I understand the main layout options (canvas, grid, stackpanel, etc.), but I dont' understand why I can't get this textblock to wrap in this scenario. Thanks!

    Read the article

  • MS Chart in WPF, Setting the DataSource is not creating the Series

    - by Shaik Phakeer
    Hi All, Here I am trying to assign the datasource (using same code given in the sample application) and create a graph, only difference is i am doing it in WPF WindowsFormsHost. due to some reason the datasource is not being assigned properly and i am not able to see the series ("Series 1") being created. wired thing is that it is working in the Windows Forms application but not in the WPF one. am i missing something and can somebody help me? Thanks <Window x:Class="SEDC.MDM.WinUI.WindowsFormsHostWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" xmlns:CHR="clr- namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.Dat aVisualization" Title="HostingWfInWpf" Height="230" Width="338"> <Grid x:Name="grid1"> </Grid> </Window> private void drawChartDataBinding() { System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); string fileNameString = @"C:\Users\Shaik\MSChart\WinSamples\WinSamples\data\chartdata.mdb"; // initialize a connection string string myConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileNameString; // define the database query string mySelectQuery = "SELECT * FROM REPS;"; // create a database connection object using the connection string OleDbConnection myConnection = new OleDbConnection(myConnectionString); // create a database command on the connection using query OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection); Chart Chart1 = new Chart(); // set chart data source Chart1.DataSource = myCommand; // set series members names for the X and Y values Chart1.Series"Series 1".XValueMember = "Name"; Chart1.Series"Series 1".YValueMembers = "Sales"; // data bind to the selected data source Chart1.DataBind(); myCommand.Dispose(); myConnection.Close(); host.Child = Chart1; this.grid1.Children.Add(host); } Shaik

    Read the article

  • Best way to convert wpf triggers to silverlight?

    - by Stewart Armbrecht
    I have developed several custom controls in a wpf application that use triggers. what is the fastest way to convert the code so that I have a single code base that works both in the wpf application and the silverlight applicaiton. Here is a sample of the code: <Style x:Key="sButtonAction" TargetType="Button"> <!--<Setter Property="BitmapEffect" Value="{StaticResource BannerEffect}" />--> <Setter Property="Height" Value="25" /> <Setter Property="Margin" Value="4" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border x:Name="PART_Border" CornerRadius="10" BorderThickness="{StaticResource sBorderThicknessStandard}" BorderBrush="{StaticResource bColorBorder}" Background="{StaticResource ButtonActionBackground}"> <TextBlock x:Name="PART_TextBlock" Margin="5,2,5,2" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /></TextBlock> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="PART_TextBlock" Property="Foreground" Value="#990000"></Setter> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="PART_Border" Property="Background" Value="{StaticResource ButtonActionBackgroundSelected}"></Setter> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>

    Read the article

  • Multilingual spellcheck on WPF richtextbox

    - by sub-jp
    I need to turn spellcheck on for a richtextbox, and set the language to one the user has picked from a drop down. For now, I'm just testing it by building the richtextbox in xaml and providing a language to the xaml language attribute. I've read two different resources and one says I need to set the language attribute, and the other says I need to set the xml:lang attribute. Neither seems to work. I've tried setting either one to "es" for Spanish, and I've also tried setting both to "es". I've also tried french by setting them to "fr-FR", without success. The only thing that happens is that english words aren't marked, but the other language words are marked as misspelled. I also read that I need to change the keyboard language. This would be a problem for my application as the language within the application needs to be switched on the fly, so having the end user go to their keyboard settings just so spellcheck will work is a problem. However, I've changed my keyboard settings, and spell check still does not work properly. This time it doesn't mark anything as misspelled, even misspelled english words. What am I missing? Edit: some links to my references above http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck(v=VS.100).aspx http://www.dev102.com/2008/03/25/customize-spellcheck-on-wpf-text-controls/ http://books.google.com/books?id=clLc5BBHqRMC&pg=PA121&lpg=PA121&dq=C%23+wpf+enable+spellcheck&source=bl&ots=_r59pZRDjP&sig=yHMBc39EHKK5gaRMzxlBaEsY890&hl=en&ei=oXnIS8zWH4G88gaq48yGBw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBMQ6AEwBQ#v=onepage&q&f=false

    Read the article

  • How to implement DisplayMemberPath for my Wpf UserControl?

    - by Bevan
    I'm writing a WPF User Control for my application, wrapping a ListBox and a few other items. The ListBox has a new ItemTemplate that presents four pieces of information for each item in my list. I can hard code each of the four bindings to specific properties on my list items and they display fine. However, I want my UserControl to be a bit more flexible. On ListBox and ComboBox there is a property DisplayMemberPath (inherited from ItemsControl) that seems to "inject" the appropriate property binding into the standard ItemTemplate. How do I achieve the same result with my user control? I'd like to set up four new properties to allow configuration of the information displayed: public string LabelDisplayPath { get; set; } public string MetricDisplayPath { get; set; } public string TitleDisplayPath { get; set; } public string SubtitleDisplayPath { get; set; } Reviewing ItemsControl.DisplayMemberPath with Reflector seems to go down the rabbit hole, I haven't been able to fathom how it works. Also, if I'm completely off course - and there's another, more "WPF" technique that I should be using instead, please point me in that direction.

    Read the article

  • Can WPF based ActiveX control use Reg-Free-COM

    - by embnut
    I have a WPF based ActiveX control (COM interop). I am able to use it correctly by registering the control. When I tried to Reg-Free-COM (using manifest files) the control seems to be activated, but the events (such as mouse click, RequestBringIntoView etc) dont respond. Interestingly, Double click and tab key works. I read in the this article http://blogs.msdn.com/karstenj/archive/2006/10/09/activex-wpf-gadget.aspx that " ... These upsides come with a price: the ActiveX control must be registered in the registry, which requires some kind of installation such as an .msi. The default gadget installation process cannot install ActiveX. The ActiveX control can't be access via reg-free COM. ..." Has anybody had a similar experience? Can anyone explain what is going on? Additional details: When the control is activated after it has been registered it appears as part of the COM client's UI. The control does not receive focus, its elements receive it. When using reg-free-com the control does not load correctly. 1) The control receives focus instead of its sub elements 2) The control has areas that are black instead of the windows default color 3) when I tab in and out of the control or double click it, it's subelements receive focus, the control starts receiving events and the black areas are replaced by the correct color

    Read the article

  • Trouble binding WPF Menu to ItemsSource

    - by chaiguy
    I would like to avoid having to build a menu manually in XAML or code, by binding to a list of ICommand-derived objects. However, I'm experiencing a bit of a problem where the resulting menu has two levels of menu-items (i.e. each MenuItem is contained in a MenuItem): My guess is that this is happening because WPF is automatically generating a MenuItem for my binding, but the "viewer" I'm using actually already is a MenuItem (it's derived from MenuItem): <ContextMenu x:Name="selectionContextMenu" ItemsSource="{Binding Source={x:Static OrangeNote:Note.MultiCommands}}" ItemContainerStyleSelector="{StaticResource separatorStyleSelector}"> <ContextMenu.ItemTemplate> <DataTemplate> <Viewers:NoteCommandMenuItemViewer CommandParameter="{Binding Source={x:Static OrangeNote:App.Screen}, Path=SelectedNotes}" /> </DataTemplate> </ContextMenu.ItemTemplate> </ContextMenu> (The ItemContainerStyleSelector is from http://bea.stollnitz.com/blog/?p=23, which allows me to have Separator elements inside my bound source.) So, the menu is bound to a collection of ICommands, and each item's CommandParameter is set to the same global target (which happens to be a collection, but that's not important). My question is, is there any way I can bind this such that WPF doesn't automatically wrap each item in a MenuItem?

    Read the article

  • C# WPF DataBind boolean

    - by jtdangelo
    I have been using this website to learn a lot about C# for a while, but this is my first time posting a question. I look forward to hearing back from some of the seasoned C# veterans! I have been working on a C# 4.0 WPF project and need to figure out how to databind a boolean value. I have a reference to my Application.Current object in a window. My "App" object contains a boolean field called "Downloaded" that is true if the user has downloaded information from a web service. I need to databind a textbox's IsEnabled field to this Downloaded value. Any tips? Here is what I have come up with so far. (Any useful links to better learn WPF XAML are greatly appreciated!) C# Code: class MainWindow : Window { ... private App MyApp = App.Current as App; ... } XAML: <TextBox ... IsEnabled="{Binding Source=MyApp, Path=Downloaded}" /> James

    Read the article

  • WPF Sizing of Panels

    - by Mystagogue
    I'm looking for an article or overview of WPF Panel types, that explains the sizing characters of each. For example, here are the panel types: http://msdn.microsoft.com/en-us/library/ms754152.aspx#Panels_derived_elements I've learned (by experiment) that UniformGrid can be given a fixed height, or it can be "auto" where it expands to fit available space. That is great, but what I wanted was for Uniform Grid to shrink to fit its internal content (particularly content that is provided dynamically, at run-time). I don't think it has that ability. So I'd like to know either what other Panel I could use for that purpose, or what Panel I should nest the UniformGrid inside of. But I don't just want an answer to that specific question. I want the sizing dynamics and capabilities of all the Panel types, in summary form, so I can make all these choices as needed. Online I find articles that cover only half the Panel types, and don't give as much information about sizing as I'm describing. Anyone know the link (or book) that has the info I'm seeking? p.s. Since I want the UniformGrid to shrink to the dynamic content I'm providing, I could just keep track of the total height of controls placed within, and then set the height of the UniformGrid. But it would be nice if WPF took care of this for me.

    Read the article

  • Interception with Unity in Prism v2 for WPF (not working for me)

    - by Bobby Chopra
    I cannot get interception to work with Prism v2 (Oct 2009). I am trying to intercept the Setter for any Public Properties and then fire the PropertyChanged event if the property has changed. I can see that the code gets executed (by stepping through with the debugger or adding a debug point). However, the WPF Window controls that are bound to these properties do not get updated. If I subscribe to these events and print to the console, I can print out the property change notifications. So, if the View has a textbox, which updates the property on the ViewModel, then the property in the ViewModel gets updated. However, if a button on the view (implemented as a DelegateCommand) causes the property to get updated, then the textbox (TwoWay Binding Mode) that is bound to that Property is not updated even though the event is triggered and the console has printed out the information about which property was updated. Has anyone encountered this issue? Here is the sample WPF Application that I have written. Wordpress doesn't allow uploads of zip files, so I renamed it to have a pdf extension (rename the file to have a zip extension). Please let me know what I am doing wrong. Thanks in advance.

    Read the article

  • Events not sent to WPF based ActiveX control (COM interop) when using Reg-Free-COM

    - by embnut
    I have a WPF based ActiveX control (COM interop). I am able to use it correctly by registering the control. When I tried to Reg-Free-COM (using manifest files) the control seems to be activated, but the events (such as mouse click, RequestBringIntoView etc) dont respond. Interestingly, Double click and tab key works. I read in the this article http://blogs.msdn.com/karstenj/archive/2006/10/09/activex-wpf-gadget.aspx that " ... These upsides come with a price: the ActiveX control must be registered in the registry, which requires some kind of installation such as an .msi. The default gadget installation process cannot install ActiveX. The ActiveX control can't be access via reg-free COM. ..." Has anybody had a similar experience? Can anyone explain what is going on? Additional details: When the control is activated after it has been registered it appears as part of the COM client's UI. The control does not receive focus, its elements receive it. When using reg-free-com the control does not load correctly. 1) The control receives focus instead of its sub elements 2) The control has areas that are black instead of the windows default color 3) when I tab in and out of the control or double click it, it's subelements receive focus, the control starts receiving events and the black areas are replaced by the correct color

    Read the article

  • WPF and Prism View Overlay

    - by Zaheer
    Hi, I need some help with overlaying views using the prism framework.Its a little more complexed than that so let me explain.I could be over-thinking this as well :D i have shell (wpf window) and i have 2 views(A & B - both usercontrols) in a module. when the shell loads it loads view A. On view A i have a button to "popup" view B for some user input. so naturally i would think to some sort of modal window/control, maybe even a popup. however the problem i face with the popup is that when i move the shell the popup remains fixed and it doesnt block events in view A. I've tried disabling view A to stop events being fired and i've also tried to use a to get the view B move with the shell. Only the canvas works but i now need a way to block it tho'. Is there anyway i can overlay a view on top of another view with prism? or how does everyone else create modal popups with prism & wpf? any advise or pointers would be greatly appreciated.

    Read the article

  • How to bind a table in a dataset to a WPF datagrid in C# and XAML

    - by Jim Thomas
    I have been searching to hours for something very simple: bind a WPF datagrid to a datatable in order to see the columns at design-time. I can’t get any of the examples to work for me. Here is the C# code to populate the datatable InfoWork inside the dataset info: info = new Info(); InfoTableAdapters.InfoWorkTableAdapter adapter = new InfoTableAdapters.InfoWorkTableAdapter(); adapter.Fill(info.InfoWork); The problem is no matter how I declare ‘info’ or ‘infoWork’ Visual Studio/XAML can’t find it. I have tried: <Window.Resources> <ObjectDataProvider x:Key="infoWork" ObjectType="{x:Type local:info}" /> </Window.Resources> I have also tried this example from wpf.codeplex, but XAML doesn’t even like the “local:” keyword! <Window.Resources> <local:info x:Key="infoWork"/> </Window.Resources> There are really two main questions here: 1) How do I declare the table InfoWork in C# so that XAML can see it? I tried declaring it Public in the window class that XAML exists in with no success. 2) How do I declare the windows resource in XAML, specifcally the datatable inside the dataset? Out of curiosity, is there a reason that ItemsSource just doesn't show up as a property that be set in the properties design window?

    Read the article

  • Show cue banner for wpf ComboBox with grouping

    - by Adam Duston
    I have a ComboBox in my WPF form: <ComboBox Margin="75,0,15,102" Name="videoFormatCombo" Height="23" VerticalAlignment="Bottom" DataContext="{StaticResource GroupedVideoFormats}" ItemsSource="{Binding}" ItemTemplate="{StaticResource VideoFormatTemplate}"> <ComboBox.GroupStyle> <GroupStyle HeaderTemplate="{StaticResource GroupHeader}"/> </ComboBox.GroupStyle> </ComboBox> As you might be able to guess, GroupedVideoFormats is a CollectionViewSource with grouping. I need to get a cue banner to display for this ComboBox. I've attempted the solution that is (very verbosely) outlined in this blog post, but it will not work for a ComboBox with grouped data. The two solutions outlined in superfluousprefixhttp://stackoverflow.com/questions/2548757/how-can-the-blank-space-in-a-c-combobox-be-filled-as-a-hint-for-the-user are for Windows Forms ComboBoxes only, and won't work with WPF. If it would help to see all the original source, this particular form is on github: superfluousprefixhttp://github.com/8planes/mirovideoconverter/blob/master/MSWindows/Windows/FileSelect.xaml . It's an open-source project, so the entire project is on github: superfluousprefixhttp://github.com/8planes/mirovideoconverter/tree/master/MSWindows . Thank you for any advice! Adam P.S. stackoverflow wouldn't let me make more than one anchor tag in my post, hence the long urls with the superfluous prefix. Sorry!

    Read the article

  • WPF : Multiple views, one DataContext

    - by zapho
    Hi, I'm working on a WPF application which must handle multiple screens (two at this this time). One view can be opened on several screens and user actions must be reflected consistently on all screens. To achieve this, for a given type of view, a single DataContext is instantiated. Then, when a view is displayed on a screen, the unique DataContext is attached to it. So, one DataContext, several views (same type of view/xaml). So far so good. It works quite well in most cases. I do have a problem with a specific view which relies on ItemsControl. These ItemsControl are used to display UIElements dynamically build in the ViewModel/DataContext (C# code). These UIElements are mostly Path objects. Example : <ItemsControl ItemsSource="{Binding WindVectors}"> <ItemsControl.Template> <ControlTemplate TargetType="{x:Type ItemsControl}"> <Canvas IsItemsHost="True" /> </ControlTemplate> </ItemsControl.Template> </ItemsControl> Here, WindVectors is a ObservableCollection<UIElement>. When the view is opened the first time, everything is fine. The problem is that when the view is opened one another screen, all ItemsControl are removed from the first screen and displayed one the second screen. Other WPF components (TextBlock for instance) on this view react normally and are displayed on both screens. Any help would be greatly appreciated. Thanks. Fabrice

    Read the article

  • How to implement menuitems that depend on current selection in WPF MVVM explorer-like application

    - by Doug
    I am new to WPF and MVVM, and I am working on an application utilizing both. The application is similar to windows explorer, so consider an app with a main window with menu (ShellViewModel), a tree control (TreeViewModel), and a list control (ListViewModel). I want to implement menu items such as Edit - Delete, which deletes the currently selected item (which may be in the tree or in the list). I am using Josh Smith's RelayCommand, and binding the menuitem to a DeleteItemCommand in the ShellViewModel is easy. It seems like implementing the DeleteItemCommand, however, requires some fairly tight coupling between the ShellViewModel and the two child view models (TreeViewModel and ListViewModel) to keep track of the focus/selection and direct the action to the proper child for implementation. That seems wrong to me, and makes me think I'm missing something. Writing a focus manager and/or selection manager to do the bookkeeping does not seem too hard, and could be done without coupling the classes together. The windowing system is already keeping track of which view has the focus, and it seems like I'd be duplicating code. What I'm not sure about is how I would route the command from the ShellViewModel down to either the ListViewModel or the TreeViewModel to do the actual work without making a mess of the code. Some day, the application will be extended to include more than two children, and I want the shell to be as ignorant of the children as possible to make that extension as painless as possible. Looking at some sample WPF/MVVM applications (Karl Shifflett's CipherText, Josh Smith's MVVM Demo, etc.), I haven't seen any code that does this (or I didn't understand it). Regardless of whether you think my approach is way off base or I'm just missing a small nuance, please share your thoughts and help me get back on track. Thanks!

    Read the article

  • Baffled by differences between WPF BitmapEncoders

    - by DanM
    I wrote a little utility class that saves BitmapSource objects to image files. The image files can be either bmp, jpeg, or png. Here is the code: public class BitmapProcessor { public void SaveAsBmp(BitmapSource bitmapSource, string path) { Save(bitmapSource, path, new BmpBitmapEncoder()); } public void SaveAsJpg(BitmapSource bitmapSource, string path) { Save(bitmapSource, path, new JpegBitmapEncoder()); } public void SaveAsPng(BitmapSource bitmapSource, string path) { Save(bitmapSource, path, new PngBitmapEncoder()); } private void Save(BitmapSource bitmapSource, string path, BitmapEncoder encoder) { using (var stream = new FileStream(path, FileMode.Create)) { encoder.Frames.Add(BitmapFrame.Create(bitmapSource)); encoder.Save(stream); } } } Each of the three Save methods work, but I get unexpected results with bmp and jpeg. Png is the only format that produces an exact reproduction of what I see if I show the BitmapSource on screen using a WPF Image control. Here are the results: BMP - too dark JPEG - too saturated PNG - correct Why am I getting completely different results for different file types? I should note that the BitmapSource in my example uses an alpha value of 0.1 (which is why it appears very desaturated), but it should be possible to show the resulting colors in any image format. I know if I take a screen capture using something like HyperSnap, it will look correct regardless of what file type I save to. Here's a HyperSnap screen capture saved as a bmp: As you can see, this isn't a problem, so there's definitely something strange about WPF's image encoders. Do I have a setting wrong? Am I missing something?

    Read the article

  • Question about making Asynchronous call in C# (WPF) to COM object

    - by Andrew
    Hi, Sorry to ask such a basic question but I seem to have a brain freeze on this one! I'm calling a COM (ATL) object from my WPF project. The COM method might take a long time to complete. I thought I'd try and call it asychronously. I have a few demo lines that show the problem. private void checkBox1_Checked(object sender, RoutedEventArgs e) { //DoSomeWork(); AsyncDoWork caller = new AsyncDoWork(DoSomeWork); IAsyncResult result = caller.BeginInvoke(null, null); } private delegate void AsyncDoWork(); private void DoSomeWork() { _Server.DoWork(); } The ATL method DoWork is very exciting. It is: STDMETHODIMP CSimpleObject::DoWork(void) { Sleep(5000); return S_OK; } I had expectations that running this way would result in the checkbox being checked right away (instead of in 5 seconds) and me being able to move the WPF gui around the screen. I can't - for 5 seconds. What am I doing wrong? I'm sure it's something pretty simple. Delegate signature wrong? Thanks.

    Read the article

  • Animated transitions in WPF

    - by arconaut
    I can't figure out what I'm missing here. Here's the problem: Consider a (Control|Data)Template with a Trigger that switches visibility of some inner UI elements. E.g. show a TextBlock when IsReadOnly==true and show a TextBox when IsReadOnly==false. Everything is perfect if you do this without animation - one or two setters would do the job. But what if you want a fancy animation? Then you would specify which animations to start in EnterActions and ExitActions. But the problem is what exactly the animations should do? Modifying width/height seems really ugly, because fixed sizes in WPF are almost always a wrong way to go and also it's absolutely unflexible. So far, the best I've come up with is modifying MaxHeight/MaxWidth to some extent, this gives just a little more flexibility but still seems brutal. How do you tell WPF to animate Width/Height of an element from 0 to "as much as needed"? UPD: Currently I do animate Opacity and RenderTransform, and it works. It's just that sometimes I'd like to see animations where elements slide around without transformation. This is not a critical question, but a quite interesting one for me.

    Read the article

  • WPF Usercontrol with textboxes

    - by benPearce
    I have a WPF user control with a number of textboxes, this is hosted on a WPF window. The textboxes are not currently bound but I cannot type into any of them. I have put a breakpoint in the KeyDown event of one of the textboxes and it hits it fine and I can see the key I pressed. The textboxes are declared as <TextBox Grid.Row="3" Grid.Column="4" x:Name="PostcodeSearch" Style="{StaticResource SearchTextBox}" KeyDown="PostcodeSearch_KeyDown"/> The style is implemented as <Style x:Key="SearchTextBox" TargetType="{x:Type TextBox}"> <Setter Property="Control.Margin" Value="2"/> <Setter Property="Height" Value="20"/> <Setter Property="Width" Value="140"/> <Setter Property="HorizontalAlignment" Value="Left"/> </Style> I am hoping I have overlooked something obvious. EDIT: I only added the KeyDown and KeyUp events just to prove that the keys presses were getting through. I do not have any custom functionality.

    Read the article

  • wpf command pattern

    - by evan
    I have a wpf gui which displays a list of information in separate window and in a separate thread from the main application. As the user performs actions in the main window the side window is updated. (For example if you clicked page down in the main window a listbox in the side window would page down). Right now the architecture for this application feels very messy and I'm sure there is a cleaner way to do it. It looks like this: Main Window contains a singleton SideWindowControl which communicates with an instance of the SideWindowDisplay using events - so, for example, the pagedown button would work like: 1) the event handler of the button on the main window calls SideWindowControl.PageDown() 2) in the PageDown() function a event is created and thrown. 3) finally the gui, ShowSideWindowDisplay is subscribing to the SideWindowControl.Actions event handles the event and actually scrolls the listbox down - note because it is in a different thread it has to do that by running the command via Dispatcher.Invoke() This just seems like a very messy way to this and there must be a clearer way (The only part that can't change is that the main window and the side window must be on different threads). Perhaps using WPF commands? I'd really appreciate any suggestions!! Thanks

    Read the article

  • WPF Binding to variable / DependencyProperty

    - by Peter
    I'm playing around with WPF Binding and variables. Apparently one can only bind DependencyProperties. I have come up with the following, which works perfectly fine: The code-behind file: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public string Test { get { return (string)this.GetValue(TestProperty); } set { this.SetValue(TestProperty, value); } //set { this.SetValue(TestProperty, "BBB"); } } public static readonly DependencyProperty TestProperty = DependencyProperty.Register( "Test", typeof(string), typeof(MainWindow), new PropertyMetadata("CCC")); private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show(Test); Test = "AAA"; MessageBox.Show(Test); } } XAML: <Window x:Class="WpfApplication3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase" Title="MainWindow" Height="350" Width="525" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <Grid> <TextBox Height="31" HorizontalAlignment="Left" Margin="84,86,0,0" Name="textBox1" VerticalAlignment="Top" Width="152" Text="{Binding Test, Mode=TwoWay, diag:PresentationTraceSources.TraceLevel=High}"/> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="320,85,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <TextBox Height="31" HorizontalAlignment="Left" Margin="84,138,0,0" Name="textBox2" Text="{Binding Test, Mode=TwoWay}" VerticalAlignment="Top" Width="152" /> </Grid> The two TextBoxes update one an other. And the Button sets them to "AAA". But now I replaced the Setter function with the one that is commented out (simulating some manipulation of the given value). I would expect that whenever the property value is changed it will be reset to "BBB". It does so when you press the button, that is when you set the property in code. But it does for some reason not affect the WPF Bindings, that is you can change the TextBox contents and thus the property, but apparently the Setter is never called. I wonder why that is so, and how one would go about to achive the expected behaviour.

    Read the article

  • WPF ResourceDictionary and DynamicResource

    - by lanicor
    i am new to WPF so maybe this will be "noob" question but i can't find answer to it (and it seems so easy)... well i am programing WPF app and i want to use smth similar to css for webpages, so i found ResourceDictionary and tried to use it... I have main window in which i create Frame and on click some UserControl is loaded to that same Frame.I include my ResourceDictionary (root/style/Styles.xaml) to my main window like this: <Window.Resources> <ResourceDictionary x:Key="styles" Source="style/Styles.xaml" /> </Window.Resources> in which i have: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ProductsRequired" TargetType="{x:Type Label}"> <Setter Property="Height" Value="28" /> ... I don't use it on my main window but want to use it on my UserControls, which are loaded to that main window and i try to use it like this: <Label Name="product1" Style="{DynamicResource ProductsRequired}" /> Warning i am getting all the time is: The resource "ProductsRequired" could not be resolved. I even tried including Styles to my UserControl <UserControl.Resources> <ResourceDictionary x:Key="styles" Source="../style/Styles.xaml" /> </UserControl.Resources> and nothing happens... Well my question is long but i wanted to be clear... :) P.S. all that logic works in C# code btw private ResourceDictionary myStyles = new ResourceDictionary(); Style ProductsRequired = myStyles["ProductsRequired"] as Style; product1.Style = ProductsRequired;

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >