wpf

silverlight grid background image

Hi, How do you set the backgound image of a grid in c# (code behind). Thanks Sp Can I do something like this? public ImageSource ImageSourcePin { set { this.DreamTypeImagePin.Background = value; } } This worked,thanks for your help public String ImageSourcePin { set { ImageBrush img = new Ima...

How to hide stringformat if data is null

Hi..How to hide a stringformat when data is not present.Consider this sample <TextBlock Text="{Binding Amount, StringFormat=Total: {0:C}}" /> in this case if Amount is null,Then it will show just Total:.How to hide this if Amount is null or empty ...

loading relative files from loaded WPF application resources

I am loading a resource.xaml file from the hard drive when the app starts for theming. When I try to load a ImageBrush I cannot specify the Uri as a relative so we get IOExeption when that style is loaded. Am I missing something? Here is a segment of my loaded xaml file with the ImageBrush <Style x:Key="theBackground" TargetType="{x:Ty...

Strange Reformat Code in Resharper

I am using ReSharper 5's "Reformat Code" feature using default settings and it converting this: _deviceInstanceView.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate() { _deviceInstanceView._DeviceInstanceContainer.UpdateLayout(); }); Into this: _deviceInstanceView.D...

Stopping WPF TextBox from growing with text

I am trying to modify my simple control so that the text box does not grow as the user types in long text. I took a look at some solutions posted here at Stackoverflow that suggest using a Grid and an invisible Border and binding the Width of the text box to the ActualWidth of the Border, but I can't seem to get it to work in my setup. ...

WPF - how to select ListBoxItem upon clicking on button in Template?

I have the following Data Template applied to a ListBox: <DataTemplate x:Key="MyTemplate" DataType="{x:Type DAL:Person}"> <StackPanel Orientation="Horizontal"> <Button Content="X" Command="{x:Static cmd:MyCommands.Remove}"/> <TextBlock Text="{Binding Person.FullName}" /> </StackPanel> </DataTemplate> When I cli...

Bind the Height of the Listbox inside the StackPanel to StackPanel`s height

Hello, I want to bind the Height of the ListBox to the Height of the StackPanel so the ListBox stretches itself Vertically so the green area is not visible anymore. When there is no item in the listbox its hidden. When there is item > 1 the ListBox must be stretching itself to the add/del buttons so the add/del buttons are always at th...

How to get the window handle of another app minimized to the system tray?

Instance A is trying to restore instance B's window, but I can't get the B's window handle. I think the problem is that the window is being minimized by B to the system tray using: this.Visibility = Visibility.Hidden; And A is trying to get B's window handle using: Process process = Process.GetCurrentProcess(); Process.GetProcessesBy...

Can't change input language of RichTextBox (WPF)

Hi, I'm trying to add to my RichEditBox'd tool bar a button to switch languages, like in MS Word. I can't seems to make this work. When I use the keyboard (alt+shift) I can switch between Hebrew and English without any problem, but the code below (and many other options I tried) is not working. The last commented line didn't work either...

wpf xaml calling a method on the current object

Im attempting to bind to the output of a method. Now I've seen examples of this using ObjectDataProvider However the problem with this is ObjectDataProvider creates a new instance of the object to call the method. Where I need the method called on the current object instance. I'm currently trying to get a converter to work. Setup: ...

WPF: What is the simplest way to get the selected text in a combo box containing only text entries?

My WPF ComboBox contains only text entries. The user will select one. What is the simplest way to get the text of the selected ComboBoxItem? Please answer in both C# and Visual Basic. Here is my ComboBox: <ComboBox Name="cboPickOne"> <ComboBoxItem>This</ComboBoxItem> <ComboBoxItem>should be</ComboBoxItem> <ComboBoxItem>easie...

Why is my wpf grid not being contained in its container?

I have a user control and within it I have two controls: 1) a search criteria control (custom user control) and 2) a Telerik RadGridView. Apart from that I have a window that is the shell for my application and in it exists three regions. When this window opens I click a button and the user control mentioned above gets inserted into on...

Why can a control draw outside its bounding box?

Here's an example image of what I mean: example The gray rectangle is the bounding box of a control that draws the blue lines and dots in it's OnRender(...) method. The red ovals mark places where it happens. Why is that possible? How can it be avoided? ...

wpf - why does this XAML override template not work

Any ideas regarding why the WPF XAML code I have is not working. I'm trying to override the WPFToolkit charting display, and have taken their default XAML and included in my Grid.Resources section as a means of overriding. Specifically I'm wanting to remove the graph markers, but this specific question pertains to clarifying my underst...

Display PostScript in WPF

I'd like to display some sheet music in my WPF application which was generated by Lilypond. Lilypond can make postscript and PNG files - I've got the latter working, but I'd much prefer the former so that the music can be resized nicely. Is there a way to do that? ...

Is there a way to make XAML / C# StringFormat show whole dollars for larger amounts but cents for smaller amounts?

In XAML, it is easy enough to use StringFormat='$#,0;$-#,0;Nil' to make a bound integer variable display as a nicely formatted dollar amount. e.g., 1024 would come out as '$1,024'. I have a need to deal with numbers ranging from a few cents up to a few hundred dollars - so 0.45 should display as '$0.45', but anything greater than some t...

How to programmatically create MenuItems (with a header) in a dynamic menu

I apologize for the length of this question - there is a question in here (at the end!), but I wanted to make sure the source code was explicit. Anyway. [Edit #2] - question title changed to more accurately reflect the... question. [Edit] - I've updated some more of the history as to how I ended up at the design / code that I did here...

WPF How to Scroll ListView embedded in Grid

Hi There I am trying to scroll a listview control in WPF which is embedded in a Grid layout control. I can't seem to achieve this. Any ideas anyone? By the way i have set the following properties on the list view in the xaml markup: <Grid> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDe...

Sometimes focus moves to first tab in TabControl when closed a dialog in another app domain

Hi everyone, I have a strange and challenging problem. I have a TabControl with two tabs. When second tab is shown, users could open a dialog with a mouse click. However, this dialog is in another app domain because of some reasons. When users close the dialog, sometimes the focus moves to the first tab, it causes that second tab is hid...

AspNetActiveDirectoryMembershipProvider & mixed logins

Hi All, I'm creating a WPF application, for which all users must be authenticated to an Active Directory. - Clientside, i'm using Client Application Services. - Server-side, i have an asp.net web application with a AspNetActiveDirectoryMembershipProvider. All is working as expected. There's one catch however. Some of the wpf applicati...