Search Results

Search found 2453 results on 99 pages for 'xaml'.

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

  • 'Content' is NOT 'Text' in XAML

    - by psheriff
    One of the key concepts in XAML is that the Content property of a XAML control like a Button or ComboBoxItem does not have to contain just textual data. In fact, Content can be almost any other XAML that you want. To illustrate here is a simple example of how to spruce up your Button controls in Silverlight. Here is some very simple XAML that consists of two Button controls within a StackPanel on a Silverlight User Control. <StackPanel>  <Button Name="btnHome"          HorizontalAlignment="Left"          Content="Home" />  <Button Name="btnLog"          HorizontalAlignment="Left"          Content="Logs" /></StackPanel> The XAML listed above will produce a Silverlight control within a Browser that looks like Figure 1.   Figure 1: Normal button controls are quite boring. With just a little bit of refactoring to move the button attributes into Styles, we can make the buttons look a little better. I am a big believer in Styles, so I typically create a Resources section within my user control where I can factor out the common attribute settings for a particular set of controls. Here is a Resources section that I added to my Silverlight user control. <UserControl.Resources>  <Style TargetType="Button"         x:Key="NormalButton">    <Setter Property="HorizontalAlignment"            Value="Left" />    <Setter Property="MinWidth"            Value="50" />    <Setter Property="Margin"            Value="10" />  </Style></UserControl.Resources> Now back in the XAML within the Grid control I update the Button controls to use the Style attribute and have each button use the Static Resource called NormalButton. <StackPanel>  <Button Name="btnHome"          Style="{StaticResource NormalButton}"          Content="Home" />  <Button Name="btnLog"          Style="{StaticResource NormalButton}"          Content="Logs" /></StackPanel> With the additional attributes set in the Resources section on the Button, the above XAML will now display the two buttons as shown in Figure 2. Figure 2: Use Resources to Make Buttons More Consistent Now let’s re-design these buttons even more. Instead of using words for each button, let’s replace the Content property to use a picture. As they say… a picture is worth a thousand words, so let’s take advantage of that. Modify each of the Button controls and eliminate the Content attribute and instead, insert an <Image> control with the <Button> and the </Button> tags. Add a ToolTip to still display the words you had before in the Content and you will now have better looking buttons, as shown in Figure 3.   Figure 3: Using pictures instead of words can be an effective method of communication The XAML to produce Figure 3 is shown in the following listing: <StackPanel>  <Button Name="btnHome"          ToolTipService.ToolTip="Home"          Style="{StaticResource NormalButton}">    <Image Style="{StaticResource NormalImage}"            Source="Images/Home.jpg" />  </Button>  <Button Name="btnLog"          ToolTipService.ToolTip="Logs"          Style="{StaticResource NormalButton}">    <Image Style="{StaticResource NormalImage}"            Source="Images/Log.jpg" />  </Button></StackPanel> You will also need to add the following XAML to the User Control’s Resources section. <Style TargetType="Image"        x:Key="NormalImage">  <Setter Property="Width"          Value="50" /></Style> Add Multiple Controls to Content Now, since the Content can be whatever we want, you could also modify the Content of each button to be a StackPanel control. Then you can have an image and text within the button. <StackPanel>  <Button Name="btnHome"          ToolTipService.ToolTip="Home"          Style="{StaticResource NormalButton}">    <StackPanel>      <Image Style="{StaticResource NormalImage}"              Source="Images/Home.jpg" />      <TextBlock Text="Home"                  Style="{StaticResource NormalTextBlock}" />    </StackPanel>  </Button>  <Button Name="btnLog"          ToolTipService.ToolTip="Logs"          Style="{StaticResource NormalButton}">    <StackPanel>      <Image Style="{StaticResource NormalImage}"              Source="Images/Log.jpg" />      <TextBlock Text="Logs"                  Style="{StaticResource NormalTextBlock}" />    </StackPanel>  </Button></StackPanel> You will need to add one more resource for the TextBlock control too. <Style TargetType="TextBlock"        x:Key="NormalTextBlock">  <Setter Property="HorizontalAlignment"          Value="Center" /></Style> All of the above will now produce the following:   Figure 4: Add multiple controls to the content to make your buttons even more interesting. Summary While this is a simple example, you can see how XAML Content has great flexibility. You could add a MediaElement control as the content of a Button and play a video within the Button. Not that you would necessarily do this, but it does work. What is nice about adding different content within the Button control is you still get the Click event and other attributes of a button, but it does necessarily look like a normal button. Good Luck with your Coding,Paul Sheriff ** SPECIAL OFFER FOR MY BLOG READERS **Visit http://www.pdsa.com/Event/Blog for a free video on Silverlight entitled "Silverlight XAML for the Complete Novice - Part 1."

    Read the article

  • Can you view XAML as "regular" .net code (c#\vb.net)?

    - by cody
    There are times when I find some example XAML that I want\need to do in code (c#\vb.net). I assume at some point the XAML becomes code, or at least IL. So my questions: Am I correct in assuming that XAML is converted to IL? (or if not IL what does it become?) If the above is correct, when does XAML become IL (or whatever it becomes)? Is there some way to see the XAML in as "code" Thanks.

    Read the article

  • Non breaking space in XAML vs. code

    - by Henrik Söderlund
    This works fine, and correctly inserts non-breaking spaces into the string: <TextBlock Text="Non&#160;Breaking&#160;Text&#160;Here"></TextBlock> But what I really need is to replace spaces with non-breaking spaces during data binding. So I wrote a simple value converter that replaces spaces with "&#160;". It does indeed replace spaces with "&#160;" but "&#160;" is displayed literally instead of showing as a non-breaking space. This is my converter: public class SpaceToNbspConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value.ToString().Replace(" ", "&#160;"); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } #endregion } Does anybody know why it works in XAML, but not in code? /Henrik

    Read the article

  • EventTrigger RoutedEvent in wpf xaml

    - by Cinaird
    I have a problem in wpf xaml and i'm pretty new on this so it may be something basic i want to rotate a ellipse 360 degree <Ellipse Name="test" Fill="Black" StrokeThickness="5" Margin="0,0,0,0" Height="66"> <Ellipse.Triggers> <EventTrigger RoutedEvent="Ellipse.Loaded" SourceName="test"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="test" Storyboard.TargetProperty="(Ellipse.RenderTransform).(RotateTransform.Angle)" From="0" To="360" Duration="0:0:0.5" RepeatBehavior="1x" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Ellipse.Triggers> </Ellipse> But nothing happens, what is wrong?

    Read the article

  • How to convert Silverlight XAML to Resource dictionary in Silverlight 2

    - by Vecdid
    I am looking for the quickest and easiest way to combine two silverlight projects. Once has controls all in Silverlight XAML the other is template driven and uses a template based on a Silverlight resource dictionary. I am looking for some advice and resources on the best and quickest way to do this. One project is based on this: Silverlight Image Slider http://www.silverlightshow.net/items/Image-slider-control-in-Silverlight-1.1.aspx the other project is based on this: Open Video Player http://www.openvideoplayer.com/ I need to move the slider into the player, but the player uses a template and I just don't get how to merge the two as I do not understand resource dictionaries as they are applied to the player. We have completely gutted and made each proiject do what we want, but heck if I can figure out how to combine them.

    Read the article

  • Visual Studio 2010 randomly crashes when editing XAML

    - by Catalin DICU
    Visual Studio 2010 randomly crashes when editing XAML in a WPF application. I'm running it on Win 7 fully updated. The installed extensions/addons are: Resharper PowerCommands The crash log is: Faulting application name: devenv.exe, version: 10.0.30319.1, time stamp: 0x4ba1fab3 Faulting module name: clr.dll, version: 4.0.30319.1, time stamp: 0x4ba1d9ef Exception code: 0xc0000005 Fault offset: 0x0017f146 Faulting process id: 0xd78 Faulting application start time: 0x01caedc7341e18e3 Faulting application path: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Anyone experiencing this ? And maybe found an explication ?

    Read the article

  • XAML trigger as StaticResource

    - by adrianm
    Why can't I create a trigger and use it as a static resource in XAML? <Window.Resources> <Trigger x:Key="ValidationTrigger" x:Shared="False" Property="Validation.HasError" Value="true"> <Setter Property="FrameworkElement.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)/ErrorContent}"/> </Trigger> <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> <Style.Triggers> <StaticResource ResourceKey="ValidationTrigger"/> </Style.Triggers> </Style> </Window.Resources> I get an errormessage at runtime "Value cannot be null. Parameter name: triggerBase Error at object 'System.Windows.Markup.StaticResourceHolder' in markup file"

    Read the article

  • [XAML] datatrigger

    - by Bert
    Hi, I have a UserControl in XAML with a couple of buttons.... When the "VideoEnable" property in my C# code change to true i want to change the color of a button. The following code compiles but crashes and I cant find a right solution <UserControl.Triggers> <DataTrigger Binding="{Binding VideoEnable}" Value="true"> <Setter Property="Button.Background" Value="Green" TargetName="VideoButton" /> <Setter Property="Grid.Background" Value="Blue" TargetName="videoGrid" /> </DataTrigger> </UserControl.Triggers>

    Read the article

  • Visual Studio Performance when editing XAML/Silverlight files

    - by driAn
    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 editing, multiple times an hour, without me doing any special actions. System: Server 2008 Std Visual Studio 2008 SP1 latest updates... I wonder if anyone else experienced this issue. Any help would be appreciated.

    Read the article

  • Translate ImageButton from C# to XAML

    - by Bill
    I worked out the C# code to create an ImageButton (below) that has three images (one base-image and two overlays) and three text boxes as the face of the button. I am inheriting from the Button class, which unfortunately includes several components that I didn't realize would surface until after coding and need to remove, namely the bright-blue surrounding border on IsMouseOver, and any visible borders between the buttons, as the buttons will end up in a wrapPanel and the borders need to be seamless. Now that the format has been worked out in C#, I expect that I need to translate to XAML so that I can create a ControlTemplate to get the functionality necessary, however I am not certain as to the process of translating from C# to XAML. Can anyone steer me in the right direction? public class ACover : Button { Image cAImage = null; Image jCImage = null; Image jCImageOverlay = null; TextBlock ATextBlock = null; TextBlock AbTextBlock = null; TextBlock ReleaseDateTextBlock = null; private string _TracksXML = ""; public ACover() { Grid cArtGrid = new Grid(); cArtGrid.Background = new SolidColorBrush(Color.FromRgb(38, 44, 64)); cArtGrid.Margin = new System.Windows.Thickness(5, 10, 5, 10); RowDefinition row1 = new RowDefinition(); row1.Height = new GridLength(225); RowDefinition row2 = new RowDefinition(); row2.Height = new GridLength(0, GridUnitType.Auto); RowDefinition row3 = new RowDefinition(); row3.Height = new GridLength(0, GridUnitType.Auto); RowDefinition row4 = new RowDefinition(); row4.Height = new GridLength(0, GridUnitType.Auto); cArtGrid.RowDefinitions.Add(row1); cArtGrid.RowDefinitions.Add(row2); cArtGrid.RowDefinitions.Add(row3); cArtGrid.RowDefinitions.Add(row4); ColumnDefinition col1 = new ColumnDefinition(); col1.Width = new GridLength(0, GridUnitType.Auto); cArtGrid.ColumnDefinitions.Add(col1); jCImage = new Image(); jCImage.Height = 240; jCImage.Width = 260; jCImage.VerticalAlignment = VerticalAlignment.Top; jCImage.Source = new BitmapImage(new Uri(Properties.Settings.Default.pathToGridImages + "jc.png", UriKind.Absolute)); cArtGrid.Children.Add(jCImage); cArtImage = new Image(); cArtImage.Height = 192; cArtImage.Width = 192; cArtImage.Margin = new System.Windows.Thickness(3, 7, 0, 0); cArtImage.VerticalAlignment = VerticalAlignment.Top; cArtGrid.Children.Add(cArtImage); jCImageOverlay = new Image(); jCImageOverlay.Height = 192; jCImageOverlay.Width = 192; jCImageOverlay.Margin = new System.Windows.Thickness(3, 7, 0, 0); jCImageOverlay.VerticalAlignment = VerticalAlignment.Top; jCImageOverlay.Source = new BitmapImage(new Uri( Properties.Settings.Default.pathToGridImages + "jc-overlay.png", UriKind.Absolute)); coverArtGrid.Children.Add(jCImageOverlay); ATextBlock = new TextBlock(); ATextBlock.Foreground = new SolidColorBrush(Color.FromRgb(173, 176, 198)); ATextBlock.Margin = new Thickness(10, -10, 0, 0); cArtGrid.Children.Add(ATextBlock); AlTextBlock = new TextBlock(); AlTextBlock.Margin = new Thickness(10, 0, 0, 0); AlTextBlock.Foreground = new SolidColorBrush(Color.FromRgb(173, 176, 198)); cArtGrid.Children.Add(AlTextBlock); RDTextBlock = new TextBlock(); RDTextBlock.Margin = new Thickness(10, 0, 0, 0); RDTextBlock.Foreground = new SolidColorBrush(Color.FromRgb(173, 176, 198)); cArtGrid.Children.Add(RDTextBlock); Grid.SetColumn(jCImage, 0); Grid.SetRow(jCImage, 0); Grid.SetColumn(jCImageOverlay, 0); Grid.SetRow(jCImageOverlay, 0); Grid.SetColumn(cArtImage, 0); Grid.SetRow(cArtImage, 0); Grid.SetColumn(ATextBlock, 0); Grid.SetRow(ATextBlock, 1); Grid.SetColumn(AlTextBlock, 0); Grid.SetRow(AlTextBlock, 2); Grid.SetColumn(RDTextBlock, 0); Grid.SetRow(RDTextBlock, 3); this.Content = cArtGrid; } public string A { get { if (ATextBlock != null) return ATextBlock.Text; else return String.Empty; } set { if (ATextBlock != null) ATextBlock.Text = value; } } public string Al { get { if (AlTextBlock != null) return AlTextBlock.Text; else return String.Empty; } set { if (AlTextBlock != null) AlTextBlock.Text = value; } } public string RD { get { if (RDTextBlock != null) return RDTextBlock.Text; else return String.Empty; } set { if (RDTextBlock != null) RDTextBlock.Text = value; } } public ImageSource Image { get { if (cArtImage != null) return cArtImage.Source; else return null; } set { if (cArtImage != null) cArtImage.Source = value; } } public string TracksXML { get { return _TracksXML; } set { _TracksXML = value; } } public double ImageWidth { get { if (cArtImage != null) return cArtImage.Width; else return double.NaN; } set { if (cArtImage != null) cArtImage.Width = value; } } public double ImageHeight { get { if (cArtImage != null) return cArtImage.Height; else return double.NaN; } set { if (cArtImage != null) cArtImage.Height = value; } } }

    Read the article

  • Conditional XAML

    - by Nicholas
    For easy of development I'm using a ViewBox to wrap all content inside a Window. This is because my development machine has a smaller screen than the deployment machine so using a ViewBox allows for better realisation of proportion. Obviously there is no reason for it to be there on Release versions of the code. Is there an easy method to conditionally include/exclude that 'wrapping' ViewBox in XAML? E.g. <Window> <Viewbox> <UserControl /*Content*/> </Viewbox> </Window>

    Read the article

  • User defined top level control in XAML

    - by luke
    A normal UserControl looks like this in XAML: <UserControl x:Class="mynamespace.foo" ...namespaces...> <!-- content --> </UserControl> I'd like to be able to define my own top level object, along the lines of: <MyControl x:Class="mynamespace.mycontrol" ...namespaces...> <!-- content --> </UserControl> Where MyControl derives from a UserControl itself. Of course the compiler complains about "MyControl" not being found. Is there a way around this?

    Read the article

  • "Genie" animation effect in XAML

    - by ScottCate
    What would the XAML look like to create a Genie animation effect? Take an object of any size/shape, and "Genie" it to another Minimized location. Kind of like the OSX window minimize. Maybe even a little fancier through a smoke-like effect where the path is more switch back, instead of a simple funnel (if that makes any sense). I'm guessing that there is some sort of Path that could be drawn, and the shape could move and transform along that path. Just a wild guess. Thanks for your ideas.

    Read the article

  • ScrollViewer GridView XAML

    - by Michel Bakker
    I am currently building a Windows 8 XAML C# application. In a page I have a scrollviewer for horizontal swiping and scrolling. I have several controls in it which work really well with the scorllviewer. But when you scroll and your cursor is on top of the ListView / GridView, then that control will handle scrollnig instead of the scrollviewer. With swiping this doesn't happen, but with the mouse scrollwheel it stops the scrollvieweing scroll. Does anybody know how to disable this behavior or have a workaround?

    Read the article

  • Using image resource in XAML markup?

    - by Jeff Dahmer
    I'm trying to add little icons to my tabs in WPF but having trouble with how to set up the binding. <TabItem.Header> <StackPanel Orientation="Horizontal"> <Image Source="{Binding Source=prop:Resources.eye}" /> <Label VerticalAlignment="Center">Header</Label> </StackPanel> </TabItem.Header> The xmlns:prop is set up for the local project's Properties, I am pulling other values from it elsewhere so I know that the namespace works. The markup above compiles fine BUT I don't see the eye image in the tab. Also, is there any way to set this up into a template? I'm fairly new to XAML/WPF and each tab will have its own image...

    Read the article

  • Set Validation Tooltip in CodeBehind instead of XAML

    - by KrisTrip
    I would like to know how to translate the following code to codebehind instead of XAML: <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> The part I can't figure out is the Path portion. I have the following but it doesn't work: new Trigger { Property = Validation.HasErrorProperty, Value = true, Setters = { new Setter { Property = Control.ToolTipProperty, // This part doesn't seem to work Value = new Binding("(Validation.Errors)[0].ErrorContent"){RelativeSource = RelativeSource.Self} } } } Help?

    Read the article

  • Xaml TabControl in the top of window

    - by Rodionov Stepan
    http://dl.dropbox.com/u/59774606/so_question_pic.png Hi All! I have a trouble with xaml-markup design that is shown on a picture. How to place window buttons in one line with tab item headers TAB1,TAB2,TAB3? I use custom control for window buttons like <Border> <StackPanel Orientation="Horizontal"> ... buttons ... </StackPanel> </Border> Does anyone have ideas how I can implement this?

    Read the article

  • How to format TimeSpan in xaml

    - by biju
    I am trying to format a textblock which is bound to a TimeSpan property.It works if the property is of type DateTime but it fails if it is a TimeSpan .I can get it done using a converter.But i am trying to find out if there is any alternatives. Sample Code public TimeSpan MyTime { get; set; } public Window2() { InitializeComponent(); MyTime = DateTime.Now.TimeOfDay; DataContext = this; } Xaml <TextBlock Text="{Binding MyTime,StringFormat=HH:mm}"/> I am expecting the textblock to show only hours and mintes.But it is showing like 19:10:46.8048860

    Read the article

  • WPF: capturing XAML into subclassed control

    - by Sonic Soul
    hello, i narrowed down what i want my wpf button to look like using XAML. now i would like to create a sub classed button control that i can just re-use w/out having to write all that markup <Button Click="TestGridColumnButton_Click" Background="Transparent" Width="16" Height="16" Margin="0,0,0,0" Padding="0,0,0,0" BorderBrush="{x:Null}"> <Button.Template> <ControlTemplate> <Image HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource SourceStyle}" /> </ControlTemplate> </Button.Template> </Button> how can i set all these properties using C# ?

    Read the article

  • Wait for animation, render to complete - XAML and C#

    - by Adam S
    Hi all. I have a situation where I am animating part of my XAML application, and I need to wait for the animation AND rendering to complete before I can move on in my code. So far the tail end of my function looks like: ProcExpandCollapse.Begin(); while (ProcExpandCollapse.GetCurrentState() != ClockState.Stopped) { } } Which, in theory, will wait until the animation is finished. But it will not wait until the rendering is finished - the thread drawing the application might still not have re-drawn the animation. The animation is expanding a UIElement, and then the next part of my code uses it's rendered size to do some things. My question then is, how do I wait until my UI Element is re-rendered before moving on?

    Read the article

  • C# WPF XAML DataTable binding to relation

    - by LnDCobra
    I have 2 tables: COmpany {CompanyID, CompanyName} Deal {CompanyID, Value} And I have a listbox: <ListBox Name="Deals" Height="100" Width="420" Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="Visible" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" SelectionChanged="Deals_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding companyRowByBuyFromCompanyFK.CompanyName}" FontWeight="Bold" /> <TextBlock Text=" -> TGS -> " /> <TextBlock Text="{Binding BuyFrom}" FontWeight="Bold" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> As you can see, I want to display the CompanyName rather then the ID which is a foreign Key. The relation "companyRowByBuyFromCompanyFK" exists, as in Deals_SelectionChanged I can access companyRowByBuyFromCompanyFK property of the Deals row, and I also can access the CompanyName propert of that row. Is the reason why this is not working because XAML binding uses the [] indexer? Rather than properties on the CompanyRows in my DataTable? At the moment im getting values such as - TGS - 3 - TGS - 4 Any ideas? Edit: I still can't get this to work, What would be the best way to accomplish this? Make a converter to convert foreign keys using Table being referenced as custom parameter. Create Table View for each table? This would be long winded as I have quite a large number of tables that have foreign keys.

    Read the article

  • C# WPF XAML DataTable binding to relationship

    - by LnDCobra
    I have the following tables: Company {CompanyID, CompanyName} Deal {CompanyID, Value} And I have a listbox: <ListBox Name="Deals" Height="100" Width="420" Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="Visible" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" SelectionChanged="Deals_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding companyRowByBuyFromCompanyFK.CompanyName}" FontWeight="Bold" /> <TextBlock Text=" -> TGS -> " /> <TextBlock Text="{Binding BuyFrom}" FontWeight="Bold" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> As you can see, I want to display the CompanyName rather then the ID which is a foreign Key. The relation "companyRowByBuyFromCompanyFK" exists, as in Deals_SelectionChanged I can access companyRowByBuyFromCompanyFK property of the Deals row, and I also can access the CompanyName propert of that row. Is the reason why this is not working because XAML binding uses the [] indexer? Rather than properties on the CompanyRows in my DataTable? At the moment im getting values such as - TGS - 3 - TGS - 4 What would be the best way to accomplish this? Make a converter to convert foreign keys using Table being referenced as custom parameter. Create Table View for each table? This would be long winded as I have quite a large number of tables that have foreign keys.

    Read the article

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