xaml

Binding from context menu item to parent control

I have a control, on that control is a command called SaveToClipboardCommand. I want to bind a context menu item command to that command so that when i click it, the copy to clipboard command is executed. <Control x:Name="Control"> <Control.ContextMenu> <ContextMenu> <MenuItem Command={"Bind to SaveToClipboardCom...

How to declare a string resource that bound to a property?

As you may know, we can declare a string "variable" using resource: <sys:String x:Key="someKey">someValue</sys:String> I want to replace someValue by a binding property, how can I do it? ...

Why does this code not bind SelectedItem to a property?

Hi, I'm pretty new to XAML, and my first task in a new job is to untangle a particularly malodorous collection of spaghetti code. Learning XAML at the same time as untangling this horror-show is proving somewhat beyond me, so my apologies for the homework-level questions I'm asking, these days. Anyway, I have the following XAML code: ...

WPF - keyboard behavior in Grouped ListBox vs. Grouped ComboBox

I Want My ComboBox to Behave like The standard ListBox When my data is grouped ListCollectionView and an Expander. I've Noticed that when I use the ListBox I can Move between the item groups and open\close the expandrs, but when I try to switch the ListBox to ComboBox, I get 'trapped' in the group i'm in - While using only the keyboard....

Siliverlight: controls visibility changes alignment?

Hi guys, The following code <StackPanel Orientation="Horizontal"> <Image Source="test.jpg"/> <Image Source="test2.jpg"/> <TextBlock Text="TeStBlock"/> </StackPanel> If I am setting the visibility of the contents of the StackPanel in the codebehind and lets say I set the visibility of the Second image t...

WPF TreeView Nodes becomes unselectable after adding children nodes

I have a huge issue with the WPF TreeView. I have setup a tree that is similar to this. <TreeView DataContext="{Binding Projects}"> <Style TargetType="TreeViewItem"> <Setter Property="IsExpanded" Value="True" /> </Style> <TreeView.Resources> <HierarchicalDataTemplate x:Key="LoadTemplate"> <Grid> ...

Two-way-like binding between a Resource's property and a runtime object property.

Hello everyone, my problem is the following : I have defined a TextBox as a child of a ToolBar in a ResourceDictionary (x:Key MyToolbar). When my application loads, it places the ToolBar correctly inside the Window frame, along with its TextBox. So far, so good. Of course, I'd like that very TextBox to be two-way databound to some obj...

Force close all open popups from code

I want to cause all open popups (with StaysOpen == false) to close from code. Basically I want to simulate the user clicking the mouse (which would close the popups) from code. I don't need to actually simulate the click, I just need the resulting behavior. I've thought about just going through the visual tree looking for popups and c...

XAML - is LayoutRoot mandatory?

When you create a XAML page in Silverlight or WPF, the system creates a top level container called "LayoutRoot". Is there anything special about this name, or can the top level container be called anything (or even nothing)? ...

Silverlight XAML - does the XMLNS actually go external??

When you create a new silverlight page, you get a number of xml namespaces auto created in the user control tag. Eg - <UserControl x:Class="QuickStart.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expressi...

Silverlight XAML - UserControl vs Page

When creating Silverlight pages, when should one use "UserControl" as the base class, and when should you use "Page" as the base class? ...

In WPF, how do I set a button's click event to change a grid's visibility?

I'm trying to set a button's event to change a grid's visibility using just XAML. I'm pretty sure I should be using an EventTrigger, but I couldn't get that to work so my most recent attempt is to create a DataTrigger that is bound to a field in the view-model: <Style x:Key="PersonalInfoGridStyle" TargetType="{x:Type Grid}"> <Style....

Is there anyway of consolidating similar data bindings and/or triggers in XAML?

I have a user control that hosts other controls. The way I implemented this is via data templates that define the control that should be associated with a specific view-model. These view-models have similar properties and interaction triggers. Please see XAML snippet below. The problem with this approach is that I would have to copy-pas...

Change default highlight colour of TabItem in TabControl WPF

Hi, Im trying to change the default highlight colour of a tab item in a tab control in WPF. In the image the highlight colour is orange, I just want to know if there is away to change it to another solid colour? Here is my XAML which declares the TabControl and 2 TabItems <TabControl> <TabControl.Background> ...

How set color for cell (DataGrid WPFtoolKIt)?

i need this set RED color. how to do it? DataTable dtSet = new DataTable(); string sql = @"requevst"; using (MySqlConnection connection = ConnectToDataBase.GetConnection()) { ... int count = adapter.Fill(dtSet); } double totalPrice = 0; foreach (DataRow row in dtSet.Rows) { to...

Route KeyUpEvent from UIElement to a TextBox

How do I route the KeyUpEvent event for a UIElement to a TextBox in WPF? For example with the following objects: <Rectangle x:Name="rectangleWPF"></Rectangle> <TextBox x:Name="textBoxWPF"></TextBox> If an 'A' is pressed on rectangleWPF then an 'A' must be inserted into textBoxWPF. Then if a backspace is pressed on rectangleWPF, text...

IntelliSense doesn't work for Resources.resx file in WPF/C# project, VS2010

In my WPF 4.0 desktop-based application in order to localize my application (e.g. English & French localizations) I'm using Resources.resx file, where I type dialog name (ID) and its value for English and French localization. Everything works great, except one thing — IntelliSense of Visual Studio 2010. Let's say, I have a button: <But...

Troubleshooting WPF / Silverlight XAML databinding ?

Whenever I am doing XAML, I tend to run into problems with databinding. It is often small issues, such as misspelling a property name. My problem is, that I don't seem to receive any errors or warnings when I am trying to bind to a property that does not exist. It would be nice to get a warning, either at compile or runtime, about my e...

how to read xaml from assembly

Hi, To navigate to a specific page in the assembly, the typical code looks like: NavigationService.Navigate(new Uri("pagename.xaml", UriKind.Relative)); I was wondering if there is a way to read the contents of this XAML file or may be a way to decompile the embedded BAML file from the assembly directly. ...

How to make wrapped text in-line with button in Silverlight 4?

I would like to have some wrapped text followed by a button, but I want the button to appear immediately after the last line of text. Kind of like this: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. [The Button] Here is my current attempt at doing so, but th...