xaml

How to add condition to a WPF Context Menu?

How could I add some conditions changing list of MenuItems in a WPF Context Menu, depending on some attributes of clicked objects?: <Grid.ContextMenu> <ContextMenu> <MenuItem Name="EditStatusCm" Header="Change status" /> ... <MenuItem ... /> </ContextMenu> </Grid.ContextMenu> ...

Why can't I comment attributes in XAML?

This has been bothering me for a while, maybe I am missing something. The following throws an error with the commented attribute (expected >), but shouldn't I be able to do something like this? <Label x:Name="Gaga" FontSize="20" <!-- Content="{Binding SomethingThatIsEmptyAtDesignTime"} ...

Binding to ancestors from within a ResourceDictionary

How can I bind to a UserControl's property from within its ResourceDictionary? I want an object I declare in my resources to have the same DataContext as the UserControl it is contained in: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xm...

Is it possible to launch another view using XAML only when button is clicked?

I know that Binding in WPF is a really powerful feature, but I don't know if that is possible. My window is composed of a really simple grid: <Grid Height="593" Width="800" > <Grid.RowDefinitions> <RowDefinition Height="109*" /> <RowDefinition Height="484*" /> </Grid.RowDefinitions> <Grid.Background> ...

How to bind wpf ComboBox to Linq to SQL Foreign Key Property

I have a Linq to SQL EntitySet with a Foreign Key Relationship between two tables. The tables in question are a Task table (called Issues) and a Departments Table. The foreign key is the department name (Which is guaranteed unique). I am running into an issue in that you cannot change a Linq to SQL FK field if the corresponding data is l...

flash has mxml microsoft has xaml What has java?

Flash has MXML and Microsoft has XAML. What markup languages does Java have? ...

Is it possible to assign ToolTip text (containing non-latin characters) in a Control Template of a WPF custom control?

In a WPF app I have a custom control. I would like the ToolTip for objects, derived from this custom control, depends on a value of one of the attributes of this custom control. Is it possible to declare it in a Control Template of this custom control? Something like: <ControlTemplate> ??? // <!--XAML ToolTip declaration --> ... <Con...

WPF: Stretching multiple paths relatively.

Hi, This should be simple, but I guess I'm missing something. I have a simple user control containing a grid and 2 paths. I would like to make this user control stretchable to any desired size, keeping the same relative position of the paths (the original work has much more paths with animation). <UserControl xmlns="http://schema...

Changing the font color on a disabled checkbox in WPF

I'm hoping this is an easy answer, as I'm just learning WPF. I've got a resource dictionary that defines all our styles. Currently the checkbox style looks like: <Style x:Key="StandardCheckboxStyle" TargetType="{x:Type CheckBox}"> <Setter Property="Foreground" Value="{Binding Source={StaticResource BrandInfo}, XPath=//Colors/@TextC...

Explicitly refresh DataTemplate from a DataTemplateSelector?

Hello. I set up a ContentControl.DataTemplateSelector to my desired one. I want that according to a command or whatever, call the ContentControl to reselect the template from the selector by either xaml or code. Thank ...

How to add access keys to menu items?

<MenuItem x:Name="newProjectButton" Click="OnNewProjectButton_Click" Header="_New Project"> </MenuItem> I want to call OnNewProjectButton_Click whenever Alt+N is pressed. The code above doesn't work, unfortunately, because the handler is called only if the menu is expanded (i.e. has focus). ...

How to declare a namespace in WPF XAML?

I am trying to use in WPF a validating input of databound controls with validation rules. In the code behind file of a wpf window I have a class: public class posintValidationRule : ValidationRule { public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { ...

Overriding a templated Button's Command in WPF

I have a ControlTemplate that I'm using to change the appearance and behavior of several Buttons. I only want part of the Button to be clickable and to execute the bound Command, so I added a Button within the ControlTemplate and bound it to the template's Command property. The problem I'm having is that since I am defining the Command ...

Inline editing TextBlock in a ListBox with Data Template (WPF)

Using WPF, I have a ListBox control with a datatemplate inside it. The relevant XAML code is shown below: <ListBox Name="_todoList" Grid.Row="1" BorderThickness="2" Drop="todoList_Drop" AllowDrop="True" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Alterna...

How to show WPF ValidationResult in a seperate textblock?

I am trying to use in WPF a validating input of databound controls with validation rules. I have a posintValidationRule class: public class posintValidationRule : ValidationRule { public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { string _strInt = value.ToStri...

Xaml alternative to grid layout

I've been using grids to hold my controls for a new app. Such as; <Grid Margin="5"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="150" /> <ColumnDefinit...

TextChanged/LostFocus/etc. event for DataGridTextColumn

I have a list of object bound to a DataGrid in a WPF page and I am looking to add an object directly after the current one if the value entered in a specific column is less than a certain number. <my:DataGridTextColumn Binding="{Binding Path=Hours}"/> I cannot for the life of me figure out how to bind to an event on the underlying Tex...

WPF seemingly super-simple dependency property

I'm puzzled. I'm trying to create a user control called TranslationView. It consists pretty much entirely of a single ListView. I don't think that's important now however, because I cannot even compile my code-behind. This is the code-behind for the user control: namespace Subster { /// <summary> /// Interaction logic for Tr...

Two-Way Binding Of VerticalOffset Property on ScrollViewer?

I have a View and a ViewModel in Silverlight 3.0. The view contains a standard ScrollViewer, which contains dynamic content. Depending on the content within the ScrollViewer, the user could have scrolled half way down the content, and then performed an action that causes the ScrollViewer to load new content, but the ScrollViewer does n...

XAML foreach() Error Object reference not set to an instance of an object.

I have a strange XAML Error that comes up in Visual Studio. I have Isolated it to the code below which causes it. The XAML designer errors when the converter below is used, however the application runs just fine without error. I like to keep the code tidy and remove all warnings and errors, what do I need to do to get rid of this one? ...