xaml

Referencing XAML Custom Control names and properties within VB Code Behind

Sorry for the basic questions, but I've been searching the web for a number of days and can't find the answer to these questions. I've created a Custom Control, and I will be placing a large number of instances of that Custom Control on my xaml page. In working with that Custom Control in the VB Code Behind, how do I do the following? ...

WPF Designer "Could not create an instance of type"

In my UI XAML I'm essentially inheriting from a class "BaseView" that contains functionality common to several forms, however this is preventing the designer from displaying the form: "Could not create instance of type BaseView". The code will compile and run, but it is frustrating not to be able to see the form in the Designer. Is ther...

What is the advantage of setting DataContext in code instead of XAML?

There seem to be two main ways to define DataContext in WPF: either in code like this: App.xaml.cs (taken from the WPF MVVM Toolkit template): public partial class App : Application { private void OnStartup(object sender, StartupEventArgs e) { // Create the ViewModel and expose it using the View's DataContext ...

Binding converter as inner class?

I have a UserControl that uses a binding converter. I've made the converter an inner class of public partial class MyPanel : UserControl { public class CornerRadiusConverter : IValueConverter { How do I reference the Converter class from the XAML? The following does not work: <controls:MyPanel.CornerRadiusConverter x:Key="Cor...

Wpf - Receiving property value change notification for properties of a framework element

How to hook to the property value change notification for properties of a FrameworkElement? We are loading xaml at run time, and for each element in the visual tree, we need to hook up something to receive a property value change notification, when ever some one changes a property value of the element. What is the best way, if one exist...

liskbox selected item should highlight with some color

I have a listbox with some images.I want to hightlight the selected item with some color. Iam using wrap panel to display images horizontally with scrollviewer. Is there any way to solve my problem. ...

What is the best way to insert macros, snippets or code blocks into XAML view?

I would like to make a time-saving snippet to pop in blocks of XAML like this and then just change the values (like you can in code with e.g. "cw"-TAB or "foreach"-TAB): <Style x:Key="FirstCellStyle" TargetType="{x:Type Border}"> <Setter Property="BorderBrush" Value="Red"/> <Setter Property="MinWidth" Value="50"/> </Style> But...

I have a listbox with the following code. I am getting the error like -- a panel with isitemshost is not nested in itemscontrol. Panel mustbe nested to show and get items

I have a Listbox with below code in code b...

How to create a listbox with a scrollviewer with repeat buttons

I am developing a wpf application with a listbox having some images. also having the scrollviewer to the listbox with repeat buttons. What i want is suppose listbox lenght is 100% then scrollviewer lenght should be some 75%. I dont want scrollviewer as same length as listbox.funtionality must work for scrollviewer repeat buttons. if i cl...

i want to know what are all the triggers available for treeview

i want to know what are all the triggers available for treeview.I want to change the color of selected item in treeview. Any answers plzz.. ...

ListView scrollbar messes up my layout

Hi all, I have a WPF ListBox that typically shows 4 or 5 items. For my application that means I almost never have to display a scrollbar (there is enough space). However, in case there are more items in the list, I need to show the vertical scroll bar, but as a result my content has less space and doesn't look nice anymore on a "backd...

Why does WrapPanel wrap TextBlocks horizontally but UserControls vertically?

This correctly wraps the TextBlocks horizontally: <StackPanel DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left"> <TextBlock Text="Simple WrapPanel:" Margin="0 0 0 5"/> <WrapPanel Orientation="Horizontal"> <TextBlock Text="one"/> <TextBlock Text="two"/> <TextBlock Text="thee"/> <TextBlock...

WPF: Implementing a MediaPlayer Audio / Video Seeker

I am currently working on an MP3 player (in a WPF application) with a WPF MediaPlayer and basically, I want to implement a Song Seeker which moves along with the current playing song. I already implemented a song slider (from Sacha Barber's application) and it works when the user drags the seeker manually (as in, the song continues from...

WPF -- simple checkbox binding question

Hello, While it is trivial to store a checkbox's checked state in a variable using the checkbox's Click event, how would I do it via databinding? All the examples I have found have the UI updated from some datasource, or bind one control to another; I want to update a member variable when the checkbox is clicked. TIA for any pointers....

In WPF, is there a way to bind to sibling properties?

I have a series of TextBlock and TextBox controls. Is there a way to apply a Style to the TextBlocks such that they can databind to the control immediately after them? I'd like to be able to do something like this: <Resources..> <Style x:Key="BindToFollowingTextBoxSibling"> <Setter Property="TextBlock.Text" Value="{Bindi...

Nested WPF DataGrids

I have a DataGrid (from the toolkit) and I want to nest another DataGrid in the DataGrid.RowDetailsTemplate. The trick is I want to bring back the data from one table in the main grid and then based on row selection go and get additonal detail from a different table and show it in the DataGrid in the detail template. This is easy enough...

WPF: Is it possible to convert the following code from Procedural (C#) to Declarative (XAML) ?

I have the following content in a Window (removed unnecessary sections): XAML: <Style x:Key="itemstyle" TargetType="{x:Type ContentPresenter}"> <EventSetter Event="MouseLeftButtonDown" Handler="HandleItemClick"/> </Style> <ItemsControl ItemsSource="{Binding ArtistList}" Margin="10" Name="artist_list" ItemContainerStyle="{Stati...

Help with some very basic WPF databinding

Hi, I'm new to WPF and trying a simple example of databinding, but it's not working. My window has a TextBlock, which I bound to a property of the window object. I declared the property in code. When running this, I see the correct value appearing in the TextBlock. There's also a button, which when clicked updates the property, except...

Loop through UserControl in WPF

Hey, I was wondering if it was possible to loop through several WPF controls. So lets say I have a control that I want rendered (with different data each time) 10-20 times depending on what it has. The only alternative I found was to manually create 20 of these user controls and hide the ones I was not using. Is it possible to loop th...

Why does my converter giving an invalid cast error?

I created a Converter to convert from double to integer. But the line "return (int)value;" always gets a "specified cast is not valid." What do I have to do so that my Converter successfully converts a double and sends back an integer? Converter: namespace TestChangeAngle { [ValueConversion(typeof(double), typeof(int))] class...