xaml

How can you bind an Indexed property to a control in WPF

Given an instance of the class ThisClassShouldBeTheDataContext as the Datacontext for the view class ThisClassShouldBeTheDataContext { public Contacts Contacts {get;set;} } class Contacts { public IEnumerable<Person> Persons {get;set;} public Person this[string Name] { get { var p = from i in Persons where i.Name...

need help to convert XAML to C# code?

<!-- Base color --> <Ellipse Width="24" Height="24" Margin="10"> <Ellipse.Fill> <RadialGradientBrush GradientOrigin=".5,.8" RadiusX="0.6"> <GradientStop Color="#002255" Offset="1" /> <GradientStop Color="#00eeff" Offset="0" /> </RadialGradientBrush> </Ellipse.Fil...

WPF ContextMenu Design. How to set Background in WPF MenuItem?

I create popup menu like this. <DockPanel.ContextMenu> <ContextMenu Background="#CD252220" Opacity="0.95" Foreground="LightGray" BorderBrush="DarkGray"> <MenuItem Header="_Save Image..." x:Name="btSave" IsEnabled="False" Click="btSave_Click" Style="{StaticResource MyStyle}"> <MenuItem.Icon> <Image...

Setting WPF text to TextBlock

I know that TextBlock can present FlowDocument, for example: <TextBlock Name="txtFont"> <Run Foreground="Maroon" FontFamily="Courier New" FontSize="24">Courier New 24</Run> </TextBlock> I would like to know how to set FlowDocument that is stored in a variable to a TextBlock. I am looking for something like: string text = "<Run F...

Convert Xaml UI to .Net Compact Framework UI

Is it possible to convert Xaml into a .Net Compact Framework UI (dll, exe, etc...)? In fact any XML based representation would be nice (QT, GTK, etc...). ...

can a UserControl be internal?

I have an assembly that defines a UserControl X. Within that assembly, X is composed of subcontrols Y and Z. I would like Y and Z to be marked internal, so that only X is available to users of my assembly. I tried to accomplish this by changing the default public accessibility in the XAML and codebehind classes, writing: <UserControl...

White lines around round border at high zoom level

If I zoom large enough in xamlpadx (500%) I see while lines around the inside of the border. In my app this even happens at normal zoom level in some controls. Why is that and more important, what can I do about it? This is my XAML code: <Border Background="#000000" BorderBrush="#000000" BorderThickness="4" CornerRadius="4"> <...

WPF - How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question: How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I'm after: when an item appears in my ListBox, it should flash for a few moments if the item is 'Critical' then it should remain highlighted Currently I have a DataTemplate t...

Nested ItemsControl's and Height Adjustments in Silverlight

For an application I'm developing, I have a few nested ItemsControls that are used in the following layout some irrelevant items left out for brevity: ItemsControl (GroupItemsControl) - ItemPanel: StackPanel with vertical orientation - ItemTemplate: ScrollViewer with an ItemsControl (SliceItemsControl) inside - ItemPanel: Canvas* ...

Custom WPF Control Dependency Property Not Binding to external DP

I'm trying real hard to make this short and easy to read. I am creating a custom control that has a DP defined (RandomNumber) in the code-behind. The value of this DP is set from a click event fired by a button in my control. Here is the relevant code for this: public partial class Tester { public int RandomNumber { ge...

How to structure a 'flippable' app?

How feasible is it(and some guidance) to build a WPF(Silverlight) app in such a way that it can be flipped back and forth from Web to Desktop? Maybe some context is in order. I am a lone developer at a non-profit. I only develop in house apps that have very long life cycles with constant modifications and changes to business rules...

How can I make an image grow x % on mouseover event in wpf?

Hi, I have a ListBox containing a set of images in a C# WPF application. When the image enters the image area, that is, on the MouseEnter event, I want the image to grow approx 10 %. This is to notify the user that the mouse pointer is now on a new "clickable" image. Do anyone know how I can accomplish this? Thanx in advance! ...

After a "SetterCollectionBase" is in use (sealed), it cannot be modified.

<UserControl x:Class="FlowItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="300" Height="300"> <UserControl.Resources> <Style TargetType="Label"> <Style.Setters> <Setter Property="Background" Value="AliceBlue" ></Setter> </...

Strange behaviour of Listboxes in WPF

I have a window with two listboxes both bound to an XMLDataProvider. The SelectedItem property of Listbox1 is two-way-bound to the SelectedItem property of ListBox2. So far so good. ListBox2 contains a Styletrigger which sets IsSelected to true when the mouse hovers over an item. The corresponding item in ListBox1 is selected too becaus...

Simple Binding of Data from code behind to XAML

Hi, I am new to WPF concepts. I want to just display a string in a textbox. I tried the following C# code and XAML to bind a string to a TextBox.Text property. C# code: public partial class Window1 : Window { public int TmpVal; public string TmpStr; public Window1() { TmpVal = 50; TmpStr = "Windows Cr...

WPF: How do I set a UI Element's background property to null/nothing/default in XAML?

In code, I can set a UI element's background property to its default value by setting it to nothing/null, i.e. myControl.Background = Nothing But how do I do this in XAML? In particular, I'm doing this in a Storyboard: <Storyboard> <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" ...

WPF: How do I set a background to default in a key frame of a color animation in XAML?

From this earlier question, I learned that I can set a background to its default color in a ColorAnimation with the following: <Storyboard> <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" Duration="00:00:02.00" To="{x:Null}" /> </Storyboard> But how do I do this in a key ...

Alternative Content for a Selected ComboBoxItem

I need to place a ComboBox in a place where I have very limited space. Is there any way to show content for the selected item in the ComboBox that is different than the content that is displayed for the item in the ComboBox's Popup? As an example, Firefox does this with it's Site Search box in the top right of the browser. When you open...

Create the same border type around all my controls

I tried to create my own Border class and then insert it in my controls but then it seems I cannot assign names to everything inside the borders: .. <my:ElementBorder> <StackPanel Name="ifBlock" Background="#E0E8FF" /> </my:ElementBorder> .. How can I get around this? Can I use templating somehow for that? EDIT: Sorry that I...

Silverlight with using of DependencyProperty and ControlTemplate

Hello everyone, I'm starting to study Silverlight 3 and Visual Studio 2008. I've been trying to create Windows sidebar gadget with button controls that look like circles (I have couple of "roundish" png images). The behavior, I want, is the following: when the mouse hovers over the image it gets larger a bit. When we click on it, then i...