wpf

Empty String Check in Trigger

How can I check the empty string in triggers <Trigger Property="Source" SourceName="ControlName" Value=""> <Setter Property="Height" Value="0" TargetName="ControlName" /> </Trigger> I have set the Height of the Control to 0 if the source of the imageControl is empty string or not set? How can I do it, Basically If the image is ...

Are there any 2D game tutorials for WPF?

Hello, I'm looking for an inspiration what to add to my 2D game and so far I've found only two games (with sources) in WPF. Are 2D games in WPF so rare? Do you know about some samples? Thank you! ...

add elements to WPF Grid

I wanted to make a function that populates a Grid in WPF with pictures. So I did that: private void setCellImage(Grid g, Image img, int column, int row) { Grid.SetColumn(img, column); Grid.SetRow(img, row); if (!g.Children.Contains(img)) g.Children.Add(img); g.UpdateLayout(); } And was using it by calling in...

WPF RichTextBox - Formatting of typed text

I am applying formatting to selected tokens in a WPF RichTextBox. To do this I get a TextRange that encompasses the token that I would like to highlight. I will then change the color of the text like this: // Get start and end pointer for token TextPointer startPointer = run.ContentStart.GetPositionAtOffset(startOffset); TextPointer end...

Cleanup for control inside a FlowDocument

I have a custom control that I use inside a FlowDocument. The control uses a System.Drawing.ImageAnimator to display transparent, animated GIF images. Why is this such a pain in the butt in WPF anyway? :P In my original implementation, this was causing memory leaks when a paragraph containing the control was being deleted from the docum...

Tag Property Length

What is maximum lenght of the Tag property of the control ...

How to show rotating image if the some process is running in wpf

I want to show rotaing image when I click on tab. The tab content is some ui which takes some time to load. I want to show that rotating image for that period of time. Is there a way to do that? Actually I have tabcontrol. When I clicked on tab, its content get loaded i.e. some operation like fetching the data and loading the ui. But th...

How to add text to path?

Hi all. Te question is how to add text to path element. For example, I have path: Path firstPath = new Path(); firstPath.Stroke = Brushes.Black; firstPath.StrokeThickness = 1; myCanvas.Children.Add(firstPath); LineGeometry firstLine = new LineGeometry(); firstPath.Data = firstLine; And...

WPF Combobox binding Question

I have a 2 Table. Product ProductName CategoryID Category ID CategoryName I'm filling combobox to table named 'category'. Code Product currentProduct=datacontext.products.FirstOrDefault(); this.datacontext=currentProduct; combobox1.Itemssource=datacontext.categories; XAML <Textbox Text="{Binding Path=ProductName}"></Textbox> ...

Should I use WPF or Windows Forms Application for my project in C#?

I am developing a Client-Server based application in which client application will access server database to store billing information. It will also have report generation facility. Windows Forms is good in document printing & I don't see such facility or controls in WPF. If I am wrong then please correct me. I want database security, w...

How to Detect a Right Click on Taskbar in WPF

I've got a WPF application in C# that starts off with a loading dialog. As expected, a button for the app shows up in the Windows taskbar. I would like to detect right-clicks that might be done to that button. Ultimately, I hope to disable the right-click or simply have the loading dialog regain focus. I've seen that some people use cu...

MVVM- How can I bind to a property, which is not a DependancyProperty?

I have found this question http://stackoverflow.com/questions/2245928/mvvm-and-the-textboxs-selectedtext-property. However, I am having trouble getting the solution given to work. This is my non-working code, in which I am trying to display the first textbox's selected text in the second textbox. View: SelectedText and Text are just st...

How to get the rotation value of a UI Element in WPF

I've figured out how to assign a rotation value (element.RenderTransform = new RotateTransform(x)), but how do I get the rotation value of the element? For example, if I wanted to make one ui element have the same rotation angle as another ui element, how would I do that? ...

How to update an XBAP’s config file after deployment

Hi All, Here is my scenario and would love any feedback. We have a WPF XBAP application which gets hosted on our customer's IIS server on which we as a vendor do not have any control over. So as a part of configuration, clients first need to configure the WCF service to point to the proper endpoints. Default location for the service is...

WPF - simple relative path - FindAncestor

In the XAML below the ToolTip correctly binds to RelativeSource Self. However, I can't for the life of me work out how to get the TextBlock in the commented block to refer to SelectedItem.Description <Controls:RadComboBoxWithCommand x:Name="cmbPacking" Grid.Row="2" Grid.C...

WPF: Validating an object at submission

I am creating a WPF app using MVVM. The app manages tagged documents, called Notes, similar to blog posts. A Note has a Title, Text and a Tags collection. I want to validate a Note at the time it is submitted for two validation rules: The Title can't be empty; and The Note must have at least one Tag. If validation fails, then the Not...

DataTemplate, Style, Triggers

Could you guys help me? I have a with custom and in it: <ListBox> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush="Black" BorderThickness="2" CornerRadius="5"> <Image Source="{Binding Picture}" /> </Border> </DataTemplate> </ListBox.ItemTe...

WPF Property Data binding to negate the property

Is there any way to change the value of property at runtime in WPF data binding. Let's say my TextBox is bind to a IsAdmin property. Is there anyway I can change that property value in XAML to be !IsAdmin. I just want to negate the property so Valueconverter might be an overkill! NOTE: Without using ValueConverter ...

WPF TextBlock binding with <LineBreak/>

I have a TextBlock binding as follows in my ControlTemplate. <TextBlock Grid.Column="1" VerticalAlignment="Center" FontSize="16" FontFamily="Arial" FontWeight="Bold" Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=ButtonText}"> </TextBlock> When I set ButtonText as follows with , it doesn't work. It doesn't displ...

LINQ to Entities exceptions (ElementAtOrDefault and CompareObjectEqual)

I am working on a shipping platform which will eventually automate shipping through several major carriers. I have a ShipmentsView Usercontrol which displayes a list of Shipments (returned by EntityFramework), and when a user clicks on a shipment item, it spawns a ShipmentEditView and passes the ShipmentID (RecordKey) to that view. I i...