xaml

Windows Phone: AppBar icons appearing differently on the device

I'm mocking up an app in Expression Blend. The app bar looks fine in Blend, but when I launch the emulator the icon doesn't display properly. The XAML for the app bar: <shell:ApplicationBar x:Name="FavoritesBar" IsVisible="True" IsMenuEnabled="True"> <shell:ApplicationBarIconButton IconUri="/assets/appbar.favs.rest.png" Text=...

How do I bind touch manipulation to a UIElement property on Windows Phone 7?

I would like to have a property of a UIElement be modified when the user swipes vertically on the screen in Windows Phone 7. I can see how to do it using the OnManipulationDelta override but it seems like that should be a Xaml binding of some sort that would accomplish it in mark-up. Can you bind properties to touch manipulations? ...

Create data objects from Xaml file

Currently I am trying to load some Xaml files to create testdata. I used the Xaml files to create data for the WPF designer in Visual Studio (DesignData). Now I want to reuse them in my Unit Tests. I need to load them somehow programmatically. Here is a small test program: // The data model class TestItem { public string Name { get...

XAML arguments for Click event

I have the following XAML: <Button Name="btnJeans" Click="btnJeans_Click" Padding="-1" > <StackPanel Orientation="Horizontal" Margin="0,0,0,17" Name="jeansItem"> <!--Replace rectangle with image--> <Image Height="119" Width="82" Source="{Binding Image}" Margin="12,0,9,0"/> <StackPanel Width="311"> ...

How to add a WPF grid control from its XAML string at runtime?

Let's say we have a grid XAML like below - eg. a generated string returned from a method. <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width='*' /> <ColumnDefinition Width='*' /> </Grid.ColumnDefinitions> <TextBlock Text='id' Grid.Column='0'/> <Rectangle Fill='Black' Grid.Column='1' /> </Grid> What...

What do we use glyph for?

What is a glyph and what do we use it for especially in context of silverlight and xaml? ...

Changing a property of something in XAML from a button click

Given the following bit of XAML <Border Name="Brder" Visibility="Visible" Width="10" Height="10" Background="Red"></Border> <Button Content="Hide"></Button> How can I set the button click to change the visibility of the border (not using code behind)? I know it's trivial in code behind and the routed click event only seems to allow s...

Silverlight 3 Element binding in a datatemplate

Hi, <DataTemplate x:Key="StatusColumnTemplate"> <Canvas> <Rectangle Fill="Red" Canvas.ZIndex="1" Opacity="30" Height="{Binding Value, ElementName=Stacky}" Width="{Binding Value, ElementName=Stacky}"></Rectangle> <StackPanel x:Name="Stacky" Orientation="Horizontal"> <Image Height="16"...

How to change the access modifier of a user control

I have a user control created in xaml, lets name it "View". In the View.xaml.cs I changed the access modifier for the class View to internal: internal partial class View : ViewBase { ... } After changing the access modifier the compiler states the error: Partial declarations of 'A.B.View' have conflicting accessibility modifier...

Problem with ListBoxItem - produce "System.Windows.Data Error: 4"

Hi. I have craeted the fallowing ListBox: <ListBox x:Name="RecentItemsListBox" Grid.Row="1" BorderThickness="0" Margin="2,0,0,0" SelectionChanged="RecentItemsListBox_SelectionChanged"> <ListBox.Resources> <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Style.Trig...

Generating geographic coordinates from a map in a C# application

Hi guys, I'm currently working on a C# application. What I would like to do is display a map of the UK, just a JPEG image (if possible), which also, when clicked, generates geographic coordinates of the point clicked. Ideally what I would like to move onto is displaying a marker at two points clicked with a line drawn between them but ...

Silverlight binding in a DataGridRowGroupHeader doesn't update when DataSource changes

I have a Binding in a inline style for the DataGridRowGroupHeader like this. <sdk:DataGrid.RowGroupHeaderStyles> <Style TargetType="sdk:DataGridRowGroupHeader"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="sdk:DataGridRowGroupHeader"> <TextBlock Margin...

How to set stroke for Clip?

I would like to clip a button to a custom shape which i am able to do with the following XAML. The clipping region though doesn't have a border. What if i want to have a red border with thickness 2? What are the properties to set? <Button Content="Button" Height="79" Margin="22,10,17,10" Clip="M50.500008,20.499998 L70.090286,42.699997 L...

Do not add a event click

When you add a Click event throws System.NullReferenceException. <ListBox DockPanel.Dock="Top" DataContext="{Binding idPerson, Converter={StaticResource ConvertTrainersFromClientsKey}}" ItemsSource="{Binding}" > <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Button Content="{Binding name_trainer}" Tag="{Binding idPersonTra...

GridSplitter with min constraints

I whant a Grid layout with two rows and splitter between them. Rows should has a minimum height of 80 pixels. Next code works great: <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" MinHeight="80" /> <RowDefinition Height="5" /> <RowDefinition Height="*" MinHeight="80" /> </Grid.RowDefinitions> ...

Is there a way to call external functions from xaml?

Is there any way to call methods of external objects (for example resource objects) directly from xaml? I mean something like this: <Grid xmlns:dm="clr-namespace:MyNameSpace;assembly=MyAssembly"> <Grid.Resources> <dm:TimeSource x:Key="timesource1"/> </Grid.Resources> <Button Click="timesource_updade">Update time</But...

WP7 Popups using resources

Im trying to create my own(custom design) popup for my WP7 application. To put it shortly it should only display bing map with a drawn route and a close button. I have used the Picker Box by from Alex Yakhnin's Blog. And by his code as a reference i have made my custom xaml file with the following (only basic design, maps and button le...

How to ignore an explicit error in VS2010?

I would like VS2010 to ignore an error in XAML Code. The Reason is, it's not a real error, I have a own class of Windows and VS is not able to create an instance of it. So now it always shows "Can not create an instance of "ChildWindow"". This would not be bad, but it marks the hole file as error, and this looks realy ugly. So: I would...

DataGrid's CellEditingTemplate and focus in edit mode

I am having an issue with WPFToolkit DataGrid when a column is customized supplying both CellTemplate and CellEditingTemplate. If you take a look below, you will see my editing template has a single CheckBox. All is fine in a functional sense but when F2 is hit to edit the cell, one must also hit TAB in order for the CheckBox to receive ...

Silverlight Datagrid: Highlight an entire column when that column is sorted

I have a DataGrid in my Silverlight application that I would like to highlight an entire column when that column is sorted. It's similar in concept to this previous question: Silverlight DataGrid: Highlight an entire column. Any ideas? I've thought maybe attaching a behavior to the LayoutUpdated event and checking a cell to see if it's...