Search Results

Search found 2571 results on 103 pages for 'winrt xaml'.

Page 5/103 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Selecting a UserControl from XAML

    - by kmontgom
    I'm working on a problem right now where I need to embed a UserControl inside another UserControl. But, I need to determine at runtime which embedded UserControl to instantiate. This implies to me that some form of data binding and/or template selection mechanism has to be invoked, but I'm not sure how to proceed with the pure XAML approach. If I was to do this with code, I would define some sort of container control in the parent UserControl, and then in the code-behind, implement some logic which would instantiate the appropriate child UserControl and then insert it as Content into the specified container in the parent UserControl. Can this be done using only XAML, or is some sort of code-behind required?

    Read the article

  • How to send a list of object from my MainPage.xaml to another page

    - by LivingThing
    When navigating to another page how can i make my list of object available to another page. for example in my mainpage.xaml var data2 = from query in document.Descendants("weather") select new Forecast { date = (string)query.Element("date"), tempMaxC = (string)query.Element("tempMaxC"), tempMinC = (string)query.Element("tempMinC"), weatherIconUrl = (string)query.Element("weatherIconUrl"), }; forecasts = data2.ToList<Forecast>(); .... NavigationService.Navigate(new Uri("/WeatherInfoPage.xaml", UriKind.Relative)); and then in my other class, i want to make it available so that i can use it like this private void AddPageItem(List<Forecast> forecasts) { .. }

    Read the article

  • Displaying a list of Items in a WPF form using XAML

    - by Dave Colwell
    Hi guys, I am attempting to display a list of items (the style and controltemplate for these items are defined elsewhere) and i want to be able to add/remove as many as i want to. As i do not have infinite screen realestate I am displaying these in a ListBox control. This is the screen i have to date: What is going to happen is this. When i click the New button, i want the item to appear in the outlined area. So now for the problem: I want, when i click the New... Button, a new item to appear in the ListBox (outlined). Is it possible to do this using XAML? I am trying to work on seperating the business logic from the interface, so if there were some way to acheive this in XAML i would appreciate it. If not,can i use the custom templated item i have created in C# so that it will appear as the template specifies in the list box instead of like a normal ListBoxItem Thanks in advance!

    Read the article

  • Bogus WPF / XAML errors in Visual Studio 2010

    - by epalm
    There are bogus errors hanging around, but at runtime everything works. Right now, I'm getting Cannot locate resource 'img/icons/silk/arrow_refresh.png'. I've got a simple UserControl called ImageButton (doesn't everyone?): <UserControl x:Class="WinDispatchClientWpf.src.controls.ImageButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"> <Button Name="btnButton" Click="btnButton_Click"> <StackPanel Orientation="Horizontal"> <Image Name="btnImage" Stretch="None" /> <TextBlock Name="btnText" /> </StackPanel> </Button> </UserControl> Which does what you'd expect: [ContentProperty("Text")] public partial class ImageButton : UserControl { public String Image { set { btnImage.Source = GuiUtil.CreateBitmapImage(value); } } public String Text { set { btnText.Text = value; } } public double Gap { set { btnImage.Margin = new Thickness(0, 0, value, 0); } } public bool ToolBarStyle { set { if (value) { btnButton.Style = (Style)FindResource(ToolBar.ButtonStyleKey); } } } public bool IsCancel { set { btnButton.IsCancel = value; } } public bool IsDefault { set { btnButton.IsDefault = value; } } public event RoutedEventHandler Click; public ImageButton() { InitializeComponent(); } private void btnButton_Click(object sender, RoutedEventArgs e) { if (Click != null) { Click(sender, e); } } } Where CreateBitmapImage is the following: public static BitmapImage CreateBitmapImage(string imagePath) { BitmapImage icon = new BitmapImage(); icon.BeginInit(); icon.UriSource = new Uri(String.Format("pack://application:,,,/{0}", imagePath)); icon.EndInit(); return icon; } I can't see the design view of any xaml file that uses an ImageButton like such: <Window foo="bar" xmlns:wpfControl="clr-namespace:MyProj.src.controls"> <Grid> <wpfControl:ImageButton ToolBarStyle="True" Gap="3" Click="btnRefresh_Click" Text="Refresh" Image="img/icons/silk/arrow_refresh.png" /> </Grid> </Window> Why is VS complaining?

    Read the article

  • Binding a combobox in XAML to a childwindow property

    - by AlexB
    Hi, I want to display a child window that contains a combobox with several values coming from one of the child window's property: public partial class MyChildWindow : ChildWindow { private ObservableCollection<MyClass> _collectionToBind = // initialize and add items to collection to make sure it s not empty... public ObservableCollection<MyClass> CollectionToBind { get { return _collectionToBind; } set { _collectionToBind = value; } } } How do I bind in XAML my combobox to the ComboBoxContent collection (both are in the same class)? I've tried several things such as: <ComboBox x:Name="linkCombo" ItemsSource="{Binding Path=CollectionToBind }" DisplayMemberPath="Description"> I've only been able to bind it in the code behind file and would like to learn the XAML way to do it. Thank you!

    Read the article

  • Binding PropertyName of CollectionViewSource SortDescription in Xaml

    - by Faisal
    Here is my xaml that tells the collectionviewsource sort property name. <CollectionViewSource Source="{Binding Contacts}" x:Key="contactsCollection" Filter="CollectionViewSource_Filter"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="DisplayName" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource> The xaml above works fine but problem I have is that I don't know how to give a variable value to SortDescription PropertyName. I have a property in my viewmodel that tells which property to sort on but I am not able to bind this property to SortDescription's PropertyName field. Is there any way?

    Read the article

  • The type{0} does not support direct content - WPF / XAML

    - by Levo
    Hi there: I defined in my code two classes: a "Person" class with public "Age" and "Name" property, and a "People" class that inherits from Generic.List(of T). The code for People class is as followed: Public Class People Inherits Collections.Generic.List(Of Person) ... End Class What I want to achieve is to directly initialize the People class, and add individual Person to it in XAML, i.e.: <local:People x:Key="Familty"> <local:Person Age="11" Name="John" /> <local:Person Age="12" Name="John2" /> ... </local:People> But I keep getting an error in XAML saying: The type 'People' does not support direct content. Any idea as for how to solve this problem? Thank you very much!

    Read the article

  • XAML Converter ConvertBack

    - by MFH
    Is there a way to access the ConvertBack-Method of a Converter that implements IValueConverter directly from XAML? The basic situation is the following (relationsships): Route (1)<->(CN) Training (1)<->(CN) Kilometer The DataContext is set to a Training. From here I use the Convert-Method to access all my Kilometers. I also have a Converter from Route to IList<Training> and the ConvertBack would lookup the Route for a Training. But I seem to not be able to access that Method from XAML…

    Read the article

  • WPF Creating an instance of a class in xaml

    - by Cloverness
    Hi, I have a problem with creating the instance of a class in xaml file. I thought you can do it like this: in the resource part of the user control and then use it in the xaml file (for example bind to it). But even tough the class I created is located in the same namespace it says that: "The type was not found. Verfiy that all assemblies were built, etc". How to get it right? is there another method? Thanks for suggestions.

    Read the article

  • XAML Binding to property

    - by imslavko
    I have check box in my XAML+C# Windows Store application. Also I have bool property: WindowsStoreTestApp.SessionData.RememberUser which is public and static. I want check box's property IsChecked to be consistent (or binded, or mapped) to this bool property. I tried this: XAML <CheckBox x:Name="chbRemember1" IsChecked="{Binding Mode=TwoWay}"/> C# chbRemember1.DataContext = SessionData.RememberUser; Code for property: namespace WindowsStoreTestApp { public class SessionData { public static bool RememberUser { get; set; } } } But it doesn't seem to work. Can you help me?

    Read the article

  • Visualising a 'Smarties' lid using XAML (WPF/Silverlight, Visual Studio/Blend)

    - by Mr. Disappointment
    Hi folks, First off, to clarify something in the title which could well be ambiguous/misleading, I'd like to inform you of my definition of 'Smarties', as I know often products are available all over - only under a different alias. Smarties are a candy product in the UK, little chocolate drops covered in a crispy shell which are distributed in a card tube, this tube used to have a plastic lid/top with an individual letter on the underside (they've taken a more economical approach as of late), the lid/top of the old-style tube is the main element of this question. Familiarisation Link Lid View Link Okay, now with the seller-type pitch out of the way (no, I don't work for Nestlé ;)), hopefully the question is becoming rather clear. Essentially, I'd like to recreate one of these lids using XAML, ultimately to be utilised in a Silverlight web application. That is, I'd like to result in a reusable control, of which the following is true: It looks like a Smarties lid. The colour can be specified. The letter can be specified. The control can be rotated to display either side. The second two seem trivial, but we must bare in mind that the background colour specified will almost, if not always, be the same as the foreground, leaving a visibility issue where the character content is concerned; as for the rotation, I'm hoping this kind of functionality is reasonably available, and acceptable to implement. So, to put this out there, consider a control named SmartiesLid which derives from ToggleButton (appropriate?) and further plotted out using a style in a resource dictionary which applies to it, as follows: <Style TargetType="local:SmartiesLid"> <Setter Property="Background" Value="Red"/> <Setter Property="Foreground" Value="Red"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:SmartiesLid"> <Grid x:Name="LayoutRoot"> <Grid.ColumnDefinitions> <ColumnDefinition Width=".05*"/> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition Width=".05*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height=".05*"/> <RowDefinition/> <RowDefinition/> <RowDefinition Height=".05*"/> <RowDefinition Height=".1*"/> </Grid.RowDefinitions> <Ellipse Grid.RowSpan="4" Grid.ColumnSpan="4" Fill="{TemplateBinding Background}" Stroke="Transparent"/> <Ellipse Grid.RowSpan="2" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1" Fill="{TemplateBinding Background}" Stroke="Transparent"> <Ellipse.Effect> <DropShadowEffect Direction="280" ShadowDepth="6" BlurRadius="6"/> </Ellipse.Effect> </Ellipse> <TextBlock Grid.RowSpan="2" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1" Name="LetterTextBlock" Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontSize="190" HorizontalAlignment="Center" VerticalAlignment="Center"> </TextBlock> <!-- <Path Stretch="Fill" Grid.Row="3" Grid.RowSpan="2" Grid.Column="1" Grid.ColumnSpan="2" Fill="Black" Data="..."> How to craw the lid 'tab'? </Path> --> </Grid> <ControlTemplate.Resources> <TranslateTransform x:Key="IndentTransform" X="10" /> <RotateTransform x:Key="RotateTransform" Angle="0" /> <Storyboard x:Key="MouseOver"> </Storyboard> <Storyboard x:Key="MouseLeave"> </Storyboard> </ControlTemplate.Resources> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Trigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource MouseOver}"/> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard Storyboard="{StaticResource MouseLeave}"/> </Trigger.ExitActions> </Trigger> <Trigger Property="IsPressed" Value="true"> <Setter TargetName="LayoutRoot" Property="RenderTransform" Value="{StaticResource IndentTransform}"/> </Trigger> <Trigger Property="IsChecked" Value="true"> <Setter TargetName="LayoutRoot" Property="RenderTransform" Value="{StaticResource RotateTransform}"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="Gray"/> <Setter Property="Opacity" Value="0.5"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> With this in mind, can anyone give input on, in decreasing order of my incompetence in an area: Designing the overall look and feel of the damn thing (I'm no designer, and while I could hack away at this single control for days and potentially get something relatively useful, it's always a gamble). The particular barrier for me here is 'pathing' the tab of the lid, as you will see in the XAML as an element commented out. Should Path be used, or would it be more appropriate to transform a rectangle with rounded corners, or any specific suggestions? Bevelling the individually displayed letter; as detailed above, when the colour of both the foreground and background are the same then this will be invisible if no effects are applied, also for a decent level of realism I'd like to be able to apply such an effect/s. So far use of DropShadow and Balder3DEngine have fulfilled my requirements for graphics in XAML, how achievable is a bevel effect? Rotating the control on mouse-click, that is, showing the opposing face. Is this going to be possible using a style and XAML only for the design? Or is it that ugliness may rear it's head in the form of code-behind to show/hide embedded controls? Should the faces be separate controls and later somehow combined? Allowing the control to size dynamically. I'm supposing I will be able to convert a solid, absolute layout to a nice generic one when I actually have the former in place. Obviously this entails sizing the centralised letter and the lid 'tab', but that's it really, other than keeping the aspect ratio equal (since the ellipses grow nicely with the grid). Any suggestions to approaching this would be greatly appreciated, particularly with a dynamically growing font - I've done that before in a web-imaging scenario using code and System.Drawing, and wouldn't like to approach it in even a similar way. By the way, the reason I specify both WPF and Silverlight is that, from my current knowledge, the inputs being written targeting either of these will be fairly transferable for similar output by the other, albeit not without alterations in either scenario. The resulting application is in fact destined to be written in Silverlight, however, so I don't fancy inviting anything from WPF which will guarantee my only being able to convert 90% of it. I'll go give this little project a start, maybe in Blend(?), hopefully can catch up with some advice shortly. Thanks, Mr. D EDIT: Next question, ought this to be broken up into separate questions? :/

    Read the article

  • XAML Deserialization problem

    - by mrwayne
    Hi, I have a block of XAML of which i'm trying to deserialize. For arguments sake lets say it looks like below. <NS:SomeObject> <NS:SomeObject.SomeProperty> <NS:SomeDifferentObject SomeOtherProp="a value"/> </NS:SomeObject.SomeProperty> </NS:SomeObject> Of which i deserialise using the following code. XamlReader.Load( File.OpenRead( @"c:\SomeFile.xaml")) I have 2 solutions, one i use Unit Testing, and another i have for my web application. When i'm using the unit testing solution, it deserializes fine and works as expected. However, when i try to deserialize using my other project i keep getting an exception like the following. 'NameSpace.SomeObject' value cannot be assigned to property 'SomeProperty' of object 'NameSpace.SomeObject'. Object of Type 'NameSpace.SomeObject' cannot be converted to type 'NameSpace.SomeObject'. It's as if it is getting confused or instantiating 2 different types of objects? Note, i do not have similarly named classes or any sort of namespace conflict. The same codes executes fine in one solution and not the other. The same project files are referenced in both. Please help!

    Read the article

  • Binding ListBox to List (Collection) in XAML

    - by david2tm
    Hello, I'm learning WPF, so I'm kind of n00b in this. I saw some examples about how to do what I want to do, but nothing exactly... The question: I want to bind List to ListBox. I want to do it in XAML, w/o coding in code behind. How can I achieve that? Right now I do it that way: <!-- XAML --> <ListBox x:Name="FileList"> <ListBox.ItemTemplate> <DataTemplate> <Label Content="{Binding Path=.}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> // Code behind public MainWindow() { // ... files = new List<string>(); FileList.ItemsSource = files; } private void FolderBrowser_TextChanged(object sender, RoutedEventArgs e) { string folder = FolderBrowser.Text; files.Clear(); files.AddRange(Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories)); FileList.Items.Refresh(); } But I want to get rid of FileList.ItemsSource = files; and FileList.Items.Refresh(); in C# code. Thanks

    Read the article

  • New TabItem Content ActualHeight crashes Xaml Window

    - by Jack Navarro
    I am able to create new TabItems with Content dynamically to a new window by streaming the Xaml with XamlReader: NewWindow newWindow = new NewWindow(); newWindow.Show(); TabControl myTabCntrol = newWindow.FindName("GBtabControl") as TabControl; StringReader stringReader = new StringReader(XamlGrid); XmlReader xmlReader = XmlReader.Create(stringReader); TabItem myTabItem = new TabItem(); myTabItem.Header = qDealName; myTabItem.Content = (UIElement)XamlReader.Load(xmlReader); myTabCntrol.Items.Add(myTabItem); This works fine. It displays a new grid wrapped in a scrollviewer. The problem is access the TabItem content from the newWindow. TabItem ti = GBtabControl.SelectedItem as TabItem; string scrollvwnm = "scrollViewer" + ti.Header.ToString(); MessageBox.Show(ti.ActualHeight.ToString()); // returns 21.5 ScrollViewer scrlvwr = this.FindName(scrollvwnm) as ScrollViewer; MessageBox.Show(scrollvwnm); // Displays name double checked for accuracy MessageBox.Show(scrlvwr.ActualHeight.ToString()); //Crashes ScrollViewer scrlvwr = ti.FindName(scrollvwnm) as ScrollViewer; MessageBox.Show(scrollvwnm); // Displays name double checked for accuracy MessageBox.Show(scrlvwr.ActualHeight.ToString()); //Also Crashes Is there a method to refresh UI in XAML so the new window is able to access the newly loaded tab item content? Thanks

    Read the article

  • XAML, binding Width and Height properties to the same properties of other control

    - by JAG
    I'm trying to create a reflection effect and it's working great except that I have to hard-code some values. This is my XAML: <Grid> <Grid.RowDefinitions> <RowDefinition Height="60"/> <RowDefinition /> <RowDefinition Height="80"/> </Grid.RowDefinitions> <StackPanel Grid.Row="1" VerticalAlignment="Center"> <UserControl x:Name="CurrentPresenter" /> <Border Width="500" Height="200" > <Border.Background> <VisualBrush Visual="{Binding ElementName=CurrentPresenter}" > <VisualBrush.Transform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="500" CenterY="99" /> </TransformGroup> </VisualBrush.Transform> </VisualBrush> </Border.Background> <Border.OpacityMask> <LinearGradientBrush StartPoint="0,0" EndPoint="0,0.6"> <GradientStop Offset="-0.6" Color="Black"></GradientStop> <GradientStop Offset="0.6" Color="Transparent"></GradientStop> </LinearGradientBrush> </Border.OpacityMask> </Border> </StackPanel> </Grid> I've tried to replace Border's Width="500" and Height="200" by Width="{Binding ElementName=CurrentPresenter, Path=Width}" and Height="{Binding ElementName=CurrentPresenter, Path=Height}" but it doesn't seem to work. Wha's wrong with this code? UPDATE: If I set Width and Height here: <UserControl x:Name="CurrentPresenter" Height="200" Width="500" /> It works as expected. However it doesn't work if I set those values in the UserControl XAML. Any ideas?

    Read the article

  • How does XAML set readonly CLR properties

    - by Igor Zevaka
    I am trying to create an application bar in code for WinPhone7. The XAML that does it goes like this: <PhoneApplicationPage.ApplicationBar> <shellns:ApplicationBar Visible="True" IsMenuEnabled="True"> <shellns:ApplicationBar.Buttons> <shellns:ApplicationBarIconButton IconUri="/images/appbar.feature.search.rest.png" /> </shellns:ApplicationBar.Buttons> </shellns:ApplicationBar> </PhoneApplicationPage.ApplicationBar> So I thought I'd just rewrite it in C#: var appbar = new ApplicationBar(); var buttons = new List<ApplicationBarIconButton>(); buttons.Add(new ApplicationBarIconButton(new Uri("image.png", UrlKind.Relative)); appbar.Buttons = buttons; //error CS0200: Property or indexer 'Microsoft.Phone.Shell.ApplicationBar.Buttons' cannot be assigned to -- it is read only The only problem is that Buttons property does not have a set accessor and is defined like so: public sealed class ApplicationBar { //...Rest of the ApplicationBar class from metadata public IList Buttons { get; } } How come this can be done in XAML and not C#? Is there a special way that the objects are constructed using this syntax? More importantly, how can I recreate this in code?

    Read the article

  • WPF - Dynamically access a specific item of a collection in XAML

    - by Andy T
    Hi, I have a data source ('SampleAppearanceDefinitions'), which holds a single collection ('Definitions'). Each item in the collection has several properties, including Color, which is what I'm interested in here. I want, in XAML, to display the Color of a particular item in the collection as text. I can do this just fine using this code below... Text="{Binding Source={StaticResource SampleAppearanceDefinitions}, Path=Definitions[0].Color}" The only problem is, this requires me to hard-code the index of the item in the Definitions collection (I've used 0 in the example above). What I want to do in fact is to get that value from a property in my current DataContext ('AppearanceID'). One might imagine the correct code to look like this.... Text="{Binding Source={StaticResource SampleAppearanceDefinitions}, Path=Definitions[{Binding AppearanceID}].Color}" ...but of course, this is wrong. Can anyone tell me what the correct way to do this is? Is it possible in XAML only? It feels like it ought to be, but I can't work out or find how to do it. Any help would be greatly appreciated! Thanks! AT

    Read the article

  • Desine time XAML serialization problem in VS2010 Designer

    - by Reporting Avatar
    The wired problem is, in VS 2008, everything works fine. In VS2010 while serializing, it is missing the "ReportDimensionElements" so I'm unable to get the values back from the serialized value back from the XAML. It says, "'ReportDimensionElements' is null" am I missing anything silly. Note: I have marked the ReportDimensionElements class with [DefaultValue(null)] for avoiding {x:Null} being serialized. Will it be causing this by any way? Serialized XAML .Net 3.5 <Report> <Report.CategoricalAxis> <CategoricalAxis> <CategoricalAxis.ReportDimensionElements> <ReportDimensionElements Capacity="4"> <ReportDimensionElement DimensionName="Customer" HierarchyName="Customer Geography" LevelName="Country" /> </ReportDimensionElements> </CategoricalAxis.ReportDimensionElements> </CategoricalAxis> </Report.CategoricalAxis> </Report> .Net 4.0 <Report> <Report.CategoricalAxis> <CategoricalAxis> <CategoricalAxis.ReportDimensionElements> <ReportDimensionElement DimensionName="Customer" HierarchyName="Customer Geography" LevelName="Country" /> </CategoricalAxis.ReportDimensionElements> </CategoricalAxis> </Report.CategoricalAxis> </Report> Great Thanks

    Read the article

  • Localizing non-breaking space in Windows 8

    - by Lukas_Skywalker
    I'm trying to localize a Windows 8 Metro style app as described in a guide on MSDN. This worked very well so far, but now I'm trying to localize a string containing a non-breaking space which appears in a XAML file (originally as hexadecimal xml-escaped string: &#x00a0). Just putting the above string into the Resources.resw file does not work, it appears just as &#x00a0. What do I have to do to get a non-breaking space in my localizations?

    Read the article

  • How can i navigate one xaml page to another?

    - by programmerist
    i have 2 page i need to navigate mainpage.xaml to login.page xaml but it throws me Object reference not set to an instance of an object. in Root.Children.Clear();.... i added this codes in App.xaml: private void Application_Startup(object sender, StartupEventArgs e) { Grid myGrid = new Grid(); myGrid.Children.Add(new MainPage()); this.RootVisual = myGrid; } and than i adde some codes on main.xaml to navigate to LoginUI.xaml namespace Gen.CallCenter.UI { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Grid Root = ((Grid)(this.Parent)); Root.Children.Clear(); Root.Children.Add(new LoginUI()); } } } How can i navigate main.xaml to LoginUI.xaml ?

    Read the article

  • Styles for XAML (Silverlight &amp; WPF)

    - by GeekAgilistMercenary
    This is a quick walk through of how to setup things for skinning within a XAML Application.  First thing, find the App.xaml file within the WPF or Silverlight Project. Within the App.xaml file set some default styles for your controls.  I set the following for a button, label, and border control for an application I am creating. Button Control <Style x:Key="ButtonStyle" TargetType="Button"> <Setter Property="FontFamily" Value="Arial" /> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="FontSize" Value="14" /> <Setter Property="Width" Value="180" /> <Setter Property="Height" Value="Auto" /> <Setter Property="Margin" Value="8" /> <Setter Property="Padding" Value="8" /> <Setter Property="Foreground" Value="AliceBlue" /> <Setter Property="Background" > <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0" /> <GradientStop Color="#FF5B5757" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> Label Control <Style x:Key="LabelStyle" TargetType="Label"> <Setter Property="Width" Value="Auto"/> <Setter Property="Height" Value="28" /> <Setter Property="Foreground" Value="Black"/> <Setter Property="Margin" Value="8"/> </Style> Border Control <Style x:Key="BorderStyle" TargetType="Border"> <Setter Property="BorderThickness" Value="4"/> <Setter Property="Width" Value="Auto"/> <Setter Property="Height" Value="Auto" /> <Setter Property="Margin" Value="0,8,0,0"/> <Setter Property="CornerRadius" Value="18"/> <Setter Property="BorderBrush"> <Setter.Value> <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> <GradientStop Color="CornflowerBlue" Offset="0" /> <GradientStop Color="White" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> These provide good examples of setting individual properties to a default, such as; <Setter Property="Width" Value="Auto"/> <Setter Property="Height" Value="Auto" /> Also for settings a more complex property, such as with a LinearGradientBrush; <Setter Property="BorderBrush"> <Setter.Value> <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> <GradientStop Color="CornflowerBlue" Offset="0" /> <GradientStop Color="White" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> These property setters should be located between the opening and closing <Application.Resources></Application.Resources> tags. <Application x:Class="ScorecardAndDashboard.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> </Application.Resources> </Application> Now in the pages, user controls, or whatever you are marking up with XAML, for the Style Property just set a StaticResource such as shown below. <!-- Border Control --> <Border Name="borderPollingFrequency" Style="{StaticResource BorderStyle}"> <!-- Label Control --> <Label Content="Trigger Name:" Style="{StaticResource LabelStyle}"></Label> <!-- Button Control --> <Button Content="Save Schedule" Name="buttonSaveSchedule" Style="{StaticResource ButtonStyle}" HorizontalAlignment="Right"/> That's it.  Simple as that.  There are other ways to setup resource files that are separate from the App.xaml, but the App.xaml file is always a good quick place to start.  As moving the styles to a specific resource file later is a mere copy and paste. Original post is available along with other technical ramblings.

    Read the article

  • Transform XAML syntax from Shorthand to full syntax

    - by Emad
    Is there a tool or a simple way to transform XAML code from the shorthand syntax to the full syntax? For example: moving from something like: <_TextBox Text="{Binding Path=Formula.Production, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" to <_TextBox <_TextBox.Text <Binding Path="Formula.NumCloses" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" </Binding </TextBox.Text </TextBox ? Thanks

    Read the article

  • XAML ComboBox Bind to Method

    - by griegs
    If I have a method in my C#; public CollectionView Months { get { CollectionView retList = new Enumerations.Months().ToCollectionView<Enumerations.Months>(); return retList; } } And I have a ComboBox; <ComboBox x:Name="ddlMonth" Grid.Row="3" Grid.Column="1" ItemsSource="{Binding Source={StaticResource Months}}"/> How can I bind my ComboBox to my method? I should add I'm a complete xaml newbie.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >