xaml

Displaying a data-bound StackPanel inside a DataTemplate

I have objects I'm databinding to a ListBox in WPF. Here's what the end result should look like: ------------------------------- | Name | Opt1 | Value1 | | | Opt2 | Value2 | | | Opt3 | Value3 | | | Opt4 | Value4 | ------------------------------- Essentially i've got a DataTemplate for the ov...

How do I attach commands to the checking and unchecking of a CheckBox?

In my ViewModel I have two commands: ICommand ExecuteMeOnCheck { get; } ICommand ExecuteMeOnUncheck { get; } I wish to attach these commands to a CheckBox and have one of them execute when it is checked and the other execute when it is unchecked. What's the best way to achieve this without cluttering the View with code-behind? ...

grid xceed

hi ,How to combine dataTemplate in to style ? <Setter Property="Theme"> <Setter.Value> <xcdg:WMP11Theme/> </Setter.Value> </Setter> (datatemplate?????) </Style> I can't put datatemplate in to style , what am i doning? ...

How can I make a WPF Image disableable?

I need an Image that is grayed out when disabled (IsEnabled=False). A grayed out version of the image can be produced by reading the BitmapImage into a FormatConvertedBitmap which is shown here. I have been able to get this working with a UserControl but now I would like the same behavior in a specialized Image class for more flexibilit...

XAML markup to use DecimalConverter?

I've a Decimal retail price property that I'm binding to a TextBox e.g. Text="{Binding Path=RetailPrice}". By default this displays with all 4 decimal places showing "0.0000". I assume I can use the built in DecimalConverter to shorten this to 2 decimal places "0.00", but can't for the life of me figure out the Xaml markup for this. Or...

Xaml Layout Resources for a Web Guy

Long story short: I've been layout out UI's with Html/CSS for about 8 years now. Recently I've been dipping into Xaml/Silverlight/Wpf and really struggling with designing a UI using Xaml. I understand the basics of the Silverlight Layout Model and feel smi comfortable with using StackPanel and Grids but I'm just not picking it up as fa...

What is the difference between modifying a control by altering the control template and adding sub controls

Hi, I am new to WPF and I have a doubt in modifying a control. I came to know that one can modify a control by changing its Control Template. i.e., <Button> <Button.Template> <ControlTemplate> ... </ControlTemplate> </Button.Template> </Button> Also we can edit a control utilizing the Content Model. i.e., <Butto...

How to use a SolidColorBrush in GradientStop?

We have this standard color in our application: <SolidColorBrush x:Key="ThemeColor" Color="#FF95BBF0"/> We are trying to use it as a GradientStop but get a type-mismatch error: <GradientStop Color="{DynamicResource ThemeColor}" Offset="1" /> What is the syntax to convert this in XAML, something like this: PSEUDO-CODE: <GradientSt...

How can you get a XAML TextBlock to collapse when it contains no data?

I want to tell WPF: "If TextBlock contains no data, then don't show it." TRY #1 with a simple trigger produces the error "'Text' member is not valid because it does not have a qualifying type name.": <StackPanel Margin="10"> <TextBlock Padding="10" Background="Yellow" Text="{Binding MainMessage}"> <TextBlock.Triggers> ...

How do you switch between "pages" of a Silverlight application?

I am currently loading the default file, page.xaml, but in that page, I am loading the content from another xaml file. With each "page" change, I just load the content from a different xaml file, and on and on. Example: this.Content = new StartPage(); I'm running into some syntax issues, however, because of the way I am changing my c...

Visual Studio Performance when editing XAML/Silverlight files

When I work on Silverlight projects within Visual Studio 2008, I regularly notice that the XAML editor hangs for up to 10 seconds. This because Visual Studio consumes 100% CPU during that timeframe. Any ideas how I could fix that? I assume this is some kind of background compiling for itellisense or something similiar. It happens during...

Binding custom dependency property to custom WPF style

I have an issue when designing a inherited Expander. My intention is to have a progress bar behind the toggle button and text in the default Expander header. I have this XAML code which gives me the progress bar in the header. It is a custom style. <Style x:Key="CurrentScanExpanderStyle" TargetType="{x:Type local:ProgressExpander}"> ...

Can I declaritively create a collection of strings?

I'm just mucking about with some wpf stuff and I want to quickly create a list of strings that I can use as a resource. Can i create a list decoratively in xmal? ...

WPF - Border around an itemscontrol

Hey, I have an itemscontrol with a custom panel inside a usercontrol. The usercontrols size is only constrained by the parent window size. <UserControl> <Grid> <Border BorderBrush="DarkGray" BorderThickness="5"> <ItemsControl ItemsSource="{Binding ActiveGame.Grid.CellsFlat}"> <ItemsControl.ItemsPanel> <Ite...

WPF Control positioning difficulties...

Hi I try to do something supposed to be extrely easy but it is now 3 hours that i can't... I try to have 2 buttons "OK" and "Cancel" close to another but it does not work , whatever i do on the cancel button it makes it invisible, here is the code: <Grid x:Name="LayoutRoot" Height="242"> <Grid.ColumnDefinitions> <ColumnDefinition ...

XAML: How to define Data Templates & Styles to be used over several Projects

I'm starting to develop a Desktop application using WPF (.net 3.5 sp1, with VS only, not blend as yet). I'm at the point were I have some generic reusable components in several libraries. Where can I define my Styles & Data Templates so that they are reusable across several projects, so I can have a consistent look and feel? I've look...

Why can't I set SelectedIndex on a data-bound ComboBox?

I have two ComboBox elements, one with databinding and one without. On the one without I can set the SelectedIndex fine. But on the one that is databound, if I set the SelectedIndex, it says, "AG_E_INVALID_ARGUMENT". But if I set it to a value in the ViewModel (SelectedIndex="{Binding SelectedCustomerIndex}") then it says "Object refe...

Can you set a property on a collection of elements declaritively?

If i have a collection of elements in a control (e.g. a custom ItemsControl), can i set a property on all the children of that control through a style in a resource dictionary. For instance i would like to set the visibility on all those elements on a certain trigger. Is this possible decoratively? Cheers J ...

Silverlight color resources using A="" R="" G="" B="" cause exception in app

When defining a color resource in a Silverlight app using the syntax A="" R="" G="" B="" (any order of parameters) an exception is caused, even though the application will compile fine and display properly in Blend. Example: <UserControl.Resources> <Color x:Key="BlackBG" A="255" R="35" G="35" B="35"/> </UserControl.Resources> Th...

Programmatic databinding

How how do you do this in c#? <TextBlock Text={Binding MyProperty}/> Assume the DataContext is set to a class of Type MyClass ...