xaml

WPF won't let me put a binding on the path of a binding -- is there another way?

I have a DataTemplate that I'm using as the CellTemplate for a GridViewColumn. I want to write something like this for the DataTemplate: <DataTemplate x:Key="_myTemplate"> <TextBlock Text="{Binding Path={Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GridViewColumn}}, Path=Header}}" /> </DataT...

Dropdown button with "search" Textbox using C#

Hi, I have to add a "Search Box" with a DropDown Button for searching the books. This dropdown button should have an arrow pointing downwards and the search textbox next to it. so, wen i click on dropdown button, i should get few options (like team, personal, e........) If i select Team then the text "Search in Team" should be displayed...

Bind to ICollectionView.Count property in XAML

Hi all, I'm trying to bind a text box to the count of a filtered, collection view in XAML. It doesn't generate any errors but it also doesn't produce any output. Does anyone know how to do this? Here's are some snippets of my XAML: <Window.Resources> <CollectionViewSource x:Key="MyView" Source="{Binding MyBinding}" Filter="MyFilte...

Sharing state between ViewModels

I have two ViewModels that present the same Model to different Views. One presents the model as an item in a ListBox, the other presents it as a tab in a TabControl. The TabControl is to display tabs for the items that are selected in the ListBox, so that the tabs come and go as the selection changes. I can easily synchronise the two co...

What is the ThemeInfo attribute for?

Whenever I create a new WPF application or WPF user control library, the AssemblyInfo.cs file includes the following attribute: [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located //(used if a resource is not found in the page, // or application resource dicti...

What does RowDefinition Height="10*" mean in a XAML Grid?

I use Height="*" a bit to mean that the height of the last row should fill to the bottom of the grid. But what does "10*" mean? <Grid Name="mainGrid"> <Grid.RowDefinitions> <RowDefinition Height="100" /> <RowDefinition Height="40" /> <RowDefinition Height="10*" /> </Grid.RowDefinitions> <Grid.ColumnDefinition...

How can I get DockPanel to make the last item fill to the bottom and right?

How do I get the bottom textblock to fill up the remaining space horizontally and vertically? I've got a shell that has this region: <DockPanel Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" LastChildFill="True" Background="Orange"> <ItemsControl x:Name="MainNavigationPanel" Background="Yellow" DockPanel.Doc...

Silverlight 3 + RIA Services Data Commit Issue

Hello, I'm working on a Silverlight 3 app with RIA Services. I've got the app running but for some reason it's only reading data, not committing changes. Most of the online examples I've seen use Linq2Entities; we're using Linq2SQL (our data model is pretty good as-is without abstraction.) Here's a snippet of the Service: [EnableCli...

how to get the scroll vertical and scroll horizantal for a page created in WPF

Hi Guys, In the general xaml code, i have written as follows, Page x:Class="UI_eHTMP.Window1" Title="eHTMP Application" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="800" Width="1400" Loaded="Window_Loaded" Title="applc1" Background="OldLace"> w...

Absolute GradientStops in LinearGradientBrushes

How can I go about specifying absolute Offsets for the GradientStops in my LinearGradientBrush? I have a GridView with a LinearGradientBrush as the background: <Grid.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop Offset="0" Color="White" /> ...

How Can I Get Information About the Source Image of a WPF `<Image>` Element?

How can I get information about the source image of a WPF <Image> element? My <Image> element has its Source bound to an ImageSource property, which changes frequently. In my code behind, I need to be able to access the actual width of the current source image file (in regular pixels), for mathematical purposes. My application will pe...

WPF DataGrid - Button in a column, getting the row from which it came on the Click event handler

Hi, I've set the itemsource of my WPF Datagrid to a List of Objects returned from my DAL. I've also added an extra column which contains a button, the xaml is below. <toolkit:DataGridTemplateColumn MinWidth="100" Header="View"> <toolkit:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Click="Button_C...

How Can I Nest Custom XAML Elements?

<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Title="Window1"> <Grid> <local:ElementType x:Name="FirstElementName"> <local:ElementType x:N...

How exactly do Attached Properties work in WPF?

I'm a bit mystified as to how Attached Properties actually convey their values to either parent or child elements. TextElement.FontFamily causes child elements to inherit the value assigned to that property (a seemingly downstream operation, parent to child). Grid.Column causes a parent item to display that child in a particular position...

Using ItemTemplate for a TreeView when adding items in code

I'm adding TreeViewItems manually in code behind and would like to use a DataTemplate to display them but can't figure out how to. I'm hoping to do something like this but the items are displayed as empty headers. What am I doing wrong? XAML <Window x:Class="TreeTest.WindowTree" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/p...

silverlight datagrid - binding each row's style

hi, i've got a silverlight (v2) datagrid where some items are section headers and as such must appear with a different background colour. i'm trying to do this with the following xaml: <dg:DataGrid.RowStyle> <Style TargetType="dg:DataGridRow"> <Setter Property="Background" Value="{Binding Path=Bac...

Visual Studio 2008 freezes when I edit XAML code

A few times a day my VS2008 SP1 freezes if I edit XAML code. It just got stuck and I have to kill the process. It seems to be a problem with the IntelliSense or the spell-checking or whatever process is going on while I edit code. The problem is very apparent if I copy+paste some code. Even if it is just one word. Many times VS2008 adds ...

How do I make sure my WPF TabControl always has a selected tab when it contains at least one tab?

I have a TabControl whose items are bound to an ObservableCollection: <TabControl ItemsSource="{Binding MyObservableCollection}" /> The tabs are added and removed as expected as items are added and removed from the collection. However, the SelectedItem reverts to -1 (meaning there is no selected tab) whenever the collection is empty. ...

Stopping a programmatically instantiated storyboard

I have an EventTrigger that will stop a few storyboards that are defined in my XAML ... but now i need to stop a storyboard that I'm starting programmatically. <UserControl.Resources> <Storyboard x:Key="FadeIn"> ... Fade In Definition </StoryBoard> <Storyboard x:Key="FadeOut"> ... Fade In Definition </StoryBoard> </UserControl> <Use...

What's the Best Way to Catch the Return Key in a PasswordBox? (WPF/XAML)

What's the best way to catch the return key in a PasswordBox? (WPF/XAML) I have a TextBox field and a PasswordBox field on my login form (for username and password entry). I also have a login button which invokes the method that performs the login validation process. I need to make the Return key react the same way in the PasswordB...