Search Results

Search found 460 results on 19 pages for 'stackpanel'.

Page 12/19 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • binding a command inside a listbox item to a property on the viewmodel parent

    - by giddy
    I've been working on this for about an hour and looked at all related SO questions. My problem is very simple: I have HomePageVieModel: HomePageVieModel +IList<NewsItem> AllNewsItems +ICommand OpenNewsItem My markup: <Window DataContext="{Binding HomePageViewModel../> <ListBox ItemsSource="{Binding Path=AllNewsItems}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock> <Hyperlink Command="{Binding Path=OpenNews}"> <TextBlock Text="{Binding Path=NewsContent}" /> </Hyperlink> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> The list shows fine with all the items, but for the life of me whatever I try for the Command won't work: <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}"> I just always get : System.Windows.Data Error: 4 : Cannot find source for binding with reference .....

    Read the article

  • How to get the coordinates of an image mouse click in the event handler?

    - by Edward Tanguay
    In the following WPF app, I have an Image in a ContentControl. When the user clicks on the image, how can I get the x/y coordinates of where the mouse clicked on the image? XAML: <Window x:Class="TestClick828374.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel Margin="10"> <ContentControl Content="{Binding TheImage}" MouseDown="ContentControl_MouseDown"/> </StackPanel> </Window> Code-Behind: using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.ComponentModel; namespace TestClick828374 { public partial class Window1 : Window, INotifyPropertyChanged { #region ViewModelProperty: TheImage private Image _theImage; public Image TheImage { get { return _theImage; } set { _theImage = value; OnPropertyChanged("TheImage"); } } #endregion public Window1() { InitializeComponent(); DataContext = this; TheImage = new Image(); TheImage.Source = new BitmapImage(new Uri(@"c:\test\rectangle.png")); TheImage.Stretch = Stretch.None; TheImage.HorizontalAlignment = HorizontalAlignment.Left; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion private void ContentControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //how to get the coordinates of the mouse click here on the image? } } }

    Read the article

  • MyContainer derived from FrameworkElement with binding support.

    - by alex2k8
    To understand how the binding works, I implemented MyContainer derived from FrameworkElement. This container allowes to set Children and adds them into the logical tree. But the binding by ElementName does not work. What can I do with MyContainer to make it work, leaving the parent as FrameworkElement? C#: public class MyContainer : FrameworkElement { public MyContainer() { Children = new List<FrameworkElement>(); } public List<FrameworkElement> Children { get; set; } protected override IEnumerator LogicalChildren { get { return Children.GetEnumerator(); } } } XAML: <Window x:Class="WpfLogicalTree.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfLogicalTree" Title="Window1" Height="300" Width="300"> <StackPanel> <local:MyContainer> <local:MyContainer.Children> <TextBlock Text="Foo" x:Name="_source" /> <TextBlock Text="{Binding Path=Text, ElementName=_source}" x:Name="_target"/> </local:MyContainer.Children> </local:MyContainer> <Button Click="Button_Click">Test</Button> </StackPanel> </Window> Window1.cs private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show(_target.Text); }

    Read the article

  • binding a command inside a listbox item to a property on the viewmodel parent

    - by gideon
    I've been working on this for about an hour and looked at all related SO questions. My problem is very simple: I have HomePageVieModel: HomePageVieModel +IList<NewsItem> AllNewsItems +ICommand OpenNews My markup: <Window DataContext="{Binding HomePageViewModel../> <ListBox ItemsSource="{Binding Path=AllNewsItems}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock> <Hyperlink Command="{Binding Path=OpenNews}"> <TextBlock Text="{Binding Path=NewsContent}" /> </Hyperlink> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> The list shows fine with all the items, but for the life of me whatever I try for the Command won't work: <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}"> I just always get : System.Windows.Data Error: 4 : Cannot find source for binding with reference ..... Update I am setting my ViewModel like this? Didn't think this would matter: <Window.DataContext> <Binding Path="HomePage" Source="{StaticResource Locator}"/> </Window.DataContext> I use the ViewModelLocator class from the MVVMLight toolkit which does the magic.

    Read the article

  • Hyperlink in Silverlight AccordionItem HeaderTemplate

    - by Charlie Brown
    I have created a HeaderTemplate for my accordions where I want to display a text block on one side of the header and a hyperlink on the right side. The display is working correctly, but the click event is not called when the user clicks, I'm guessing b/c the header itself is trapping the click for expand/contract. <layoutToolkit:Accordion> <layoutToolkit:AccordionItem IsSelected="True"> <layoutToolkit:AccordionItem.HeaderTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="20"> <TextBlock Margin="0,0,700,0">Cancel Postcards</TextBlock> <HyperlinkButton Content="Next Call" Foreground="Blue" Click="NextCancel_Click" /> </StackPanel> </DataTemplate> </layoutToolkit:AccordionItem.HeaderTemplate> ..... more code .... Is there a way to get the hyperlink to respond to events without practically creating a new control?

    Read the article

  • How do I bind arrays to columns in a WPF datagrid

    - by user1432917
    I have a Log object that contains a list of Curve objects. Each curve has a Name property and an array of doubles. I want the Name to be in the column header and the data below it. I have a user control with a datagid. Here is the XAML; <UserControl x:Class="WellLab.UI.LogViewer" 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" d:DesignHeight="500" d:DesignWidth="500"> <Grid> <StackPanel Height="Auto" HorizontalAlignment="Stretch" Margin="0" Name="stackPanel1" VerticalAlignment="Stretch" Width="Auto"> <ToolBarTray Height="26" Name="toolBarTray1" Width="Auto" /> <ScrollViewer Height="Auto" Name="scrollViewer1" Width="Auto" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" CanContentScroll="True" Background="#E6ABA4A4"> <DataGrid AutoGenerateColumns="True" Height="Auto" Name="logDataGrid" Width="Auto" ItemsSource="{Binding}" HorizontalAlignment="Left"> </DataGrid> </ScrollViewer> </StackPanel> </Grid> In the code behind I have figured out how to create columns and name them, but I have not figured out how to bind the data. public partial class LogViewer { public LogViewer(Log log) { InitializeComponent(); foreach (var curve in log.Curves) { var data = curve.GetData(); var col = new DataGridTextColumn { Header = curve.Name }; logDataGrid.Columns.Add(col); } } } I wont even show the code I tried to use to bind the array "data", since nothing even came close. I am sure I am missing something simple, but after hours of searching the web, I have to come begging for an answer.

    Read the article

  • Why might a silverlight ListBox on Windows Phone not allow me scroll all the way down to the bottom?

    - by Byron Sommardahl
    I have a ListBox in a grid that gets databound when the page loads... pretty straightforward. The problem I'm having is that, after the box is databound, I can scroll... but not all the way to the bottom of the list. It stops an item or two short and won't let me scroll anymore. Here's the listbox XAML: <Grid x:Name="ContentGrid" Grid.Row="2"> <ListBox x:Name="lbFeed" ItemsSource="{Binding Items}" SelectionChanged="lbFeed_SelectionChanged" VerticalAlignment="Top" Width="480"> <ListBox.ItemTemplate> <DataTemplate x:Key="MyDataTemplate"> <StackPanel Orientation="Vertical" Width="430"> <TextBlock Text="Some text" TextAlignment="Center" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> I can post more code, but I'm still getting my feet wet in XAML and I'm not sure what might be causing this. If you need more context, let me know and I'll add it here.

    Read the article

  • Where is the "ListViewItemPlaceholderBackgroundThemeBrush" located?

    - by Dimi Toulakis
    I have a problem understanding one style definition in Windows 8 metro apps. When you create a metro style application with VS, there is also a folder named Common created. Inside this folder there is file called StandardStyles.xaml Now the following snippet is from this file: <!-- Grid-appropriate 250 pixel square item template as seen in the GroupedItemsPage and ItemsPage --> <DataTemplate x:Key="Standard250x250ItemTemplate"> <Grid HorizontalAlignment="Left" Width="250" Height="250"> <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}"> <Image Source="{Binding Image}" Stretch="UniformToFill"/> </Border> <StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}"> <TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/> <TextBlock Text="{Binding Subtitle}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/> </StackPanel> </Grid> </DataTemplate> What I do not understand here is the static resource definition, e.g. for the Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" It is not about how you work with templates and binding and resources. Where is this ListViewItemPlaceholderBackgroundThemeBrush located? Many thanks for your help. Dimi

    Read the article

  • WPF Empty Row in ItemsControl Binding with ObservableCollection

    - by YoMo
    I have ItemsControl Binding with ObservableCollection, every think is oky excipt when ObservableCollection was empty the ItemsControl showing one empty row !! <ItemsControl Visibility="Visible" ItemsSource="{Binding ocItemsinInvoice,Mode=TwoWay}" x:Name="test" Margin="10,-32,0,207" Width="412" HorizontalAlignment="Left"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="1" VerticalAlignment="Top" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button x:Name="btnOpenInvoice" Style="{StaticResource OpenInvoicesButton}" FontSize="12" Width="300" Height="60" Foreground="#ff252526"> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding Item.ItemName}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </StackPanel> </Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> How can I remove it?

    Read the article

  • Group panel of WPF ListBox

    - by rulestein
    I have a listbox that is grouping the items with a GroupStyle. I would like add a control at the bottom of the stackpanel that holds all of the groups. This additional control needs to be part of the scrolling content so that the user would scroll to the bottom of the list to see the control. If I were using a listbox without the groups, this task would be easy by modifying the ListBox template. However, with the items grouped, the ListBox template seems to only apply on a per group basis. I can modify the GroupStyle.Panel, but that doesn't allow me to add items to that panel. <ListBox> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.GroupStyle> <GroupStyle> <GroupStyle.Panel> <ItemsPanelTemplate> <VirtualizingStackPanel/> **<----- I would like to add a control to this stackpanel** </ItemsPanelTemplate> </GroupStyle.Panel> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupItem}"> <Grid> <ItemsPresenter /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </ListBox.GroupStyle> This should give an idea of what I need to do:

    Read the article

  • How to set margin for inner controls of WrapPanel

    - by Andrey Tagaew
    Hi Guys! I'm new in WPF and have a question. Here is an example that I'm using: <Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <StackPanel> <WrapPanel Orientation="Horizontal" > <Button Content="test1" Margin="10,0" Padding="10,10" /> <Button Content="test2" Margin="10,0" Padding="10,10" /> <Button Content="test3" Margin="10,0" Padding="10,10" /> <Button Content="test4" Margin="10,0" Padding="10,10" /> <Button Content="test5" Margin="10,0" Padding="10,10" /> </WrapPanel> </StackPanel> As you can see, my wrap panel has several buttons. Each button has the same margin and padding. The question is, is there a way of setting margin and padding for wrap panel, so each element inside the wrap panel may use it values? This make the code shorter and let me specify Margin and Padding only one time instead of setting it for each control in the panel. Thank you!

    Read the article

  • WPF - Extend ListView with checkable AND selectable ListViewItems

    - by Marks
    Hi there. I already read many examples on extending ListViews with checkboxes bound with IsSelected. But I want something more. I want a seperation between the checked and selected state, so i get a ListBox that has a single selected item, but can have multiple checked items. Unfortunately ListViewItem does not have a property for checked and I dont see a possibility to get the ListView to work with a custom CheckableListViewItem. Of course i could use a List of objects with a checked property as ItemSource, but I dont think thats a good way to go. Checked or not is a matter of the list or item-container, not of the object listed in it. Beside that I dont want all my classes like user, role, group to have counterparts like checkableUser, checkableRole and checkableGroup. The behaviour i want can be easyly accomblished for the UI with a <DataTemplate x:Key="CheckBoxCell"> <StackPanel Orientation="Horizontal"> <CheckBox /> </StackPanel> </DataTemplate> and a <GridViewColumn CellTemplate="{StaticResource CheckBoxCell}" Width="30"/> But without a binding on the checkbox i cant check if it is checked or not. Is there any way to accomplish something like that? The perfect solution for me would be to have listView1.SelectedItem, listView1.CheckedItems and maybe a listView1.UncheckedItems and of course listView1.CheckItem and listView1.UncheckItem. Thanks for any help.

    Read the article

  • WPF: Binding an integer to a TextBlock with TemplateBinding

    - by haagel
    I have a custom control in WPF. In this I have a DependencyProperty of the type integer. In the template for the custom control I have a TextBlock, I and would like to show the value of the integer in the TextBlock. But I can't get it to work. I'm using TemplateBinding. If I use the same code but change the type of the DependencyProperty to string it works fine. But I really want it to be an integer for the rest of my application to work. How can I do this? I've written simplified code that shows the problem. First the custom control: public class MyCustomControl : Control { static MyCustomControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomControl), new FrameworkPropertyMetadata(typeof(MyCustomControl))); MyIntegerProperty = DependencyProperty.Register("MyInteger", typeof(int), typeof(MyCustomControl), new FrameworkPropertyMetadata(0)); } public int MyInteger { get { return (int)GetValue(MyCustomControl.MyIntegerProperty); } set { SetValue(MyCustomControl.MyIntegerProperty, value); } } public static readonly DependencyProperty MyIntegerProperty; } And this is my default template: <Style TargetType="{x:Type local:MyCustomControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:MyCustomControl}"> <Border BorderThickness="1" CornerRadius="4" BorderBrush="Black" Background="Azure"> <StackPanel Orientation="Vertical"> <TextBlock Text="{TemplateBinding MyInteger}" HorizontalAlignment="Center" /> </StackPanel> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> What am I doing wrong? Thanks // David

    Read the article

  • Dynamcally resising an open Accordion

    - by alavers
    I have an Accordion and the height of its content can be dynamically resized. I would like to see the Accordion dynamically respond to the child item's height, but I'm having trouble doing this. <lt:Accordion Name="MyAccordion" SelectionMode="ZeroOrOne" HorizontalAlignment="Stretch"> <lt:AccordionItem Name="MyAccordionItem" Header="MyAccordion" IsSelected="True" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch"> <StackPanel> <Button Content="Grow" Click="Grow"/> <Button Content="Shrink" Click="Shrink"/> <TextBox Name="GrowTextBox" Text="GrowTextBox" Height="400" Background="Green" SizeChanged="GrowTextBox_SizeChanged"/> </StackPanel> </lt:AccordionItem> </lt:Accordion> private void Grow(object sender, System.Windows.RoutedEventArgs e) { GrowTextBox.Height += 100; } private void Shrink(object sender, System.Windows.RoutedEventArgs e) { GrowTextBox.Height -= 100; } private void GrowTextBox_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e) { MyAccordion.UpdateLayout(); MyAccordionItem.UpdateLayout(); } Mind you, if I collapse and then re-open the accordion, it takes shape just the way I want, but I'd like this resizing to occur immediately when the child resizes. I feebly attempted to fix this by adding a SizeChanged event handler that calls UpdateLayout() on the Accordion and AccordionItem, but this doesn't have any visual effect. I can't figure out where proper resizing takes place inside the Accordion control. Does anyone have an idea?

    Read the article

  • How can I get the mouse wheel to work correctly with the Silverlight 4 ScrollViewer

    - by Ian Oakes
    When I use the following xaml in Silverlight 4, the ScrollViewer will not recognize the mouse wheel unless I click once on the scroll bar thumb, and keep the mouse over the scroll bar, while turning the mouse wheel. <Grid x:Name="LayoutRoot" Background="White"> <ScrollViewer> <StackPanel Name="stackPanel1"> <Button Content="Button 1" Width="150" /> <Button Content="Button 2" Width="150" Margin="0,20,0,0" /> <Button Content="Button 3" Width="150" Margin="0,20,0,0" /> <Button Content="Button 4" Width="150" Margin="0,20,0,0" /> <Button Content="Button 5" Width="150" Margin="0,20,0,0" /> <Button Content="Button 6" Width="150" Margin="0,20,0,0" /> <Button Content="Button 7" Width="150" Margin="0,20,0,0" /> </StackPanel> </ScrollViewer> </Grid> Has anyone else experience this, and is there any work around?

    Read the article

  • Access property of DataContext in ItemTemplate

    - by amrinder
    My datacontext has two properties: Items which is a collection and DetailsVisiblity which is enum of type Visiblity. On the page I have a Listbox with ItemsSource="{Binding Entries}". Inside the DataTemplate, I can bind stuff to properties of Items, but how do I get access to DetailsVisiblity which is a property of DataContext? DataContext has two properties: ObservableCollection<Item> Entries, and Visibility DetailsVisiblity. Item class has two properties: Title and Details. Here is the view. How do I bind Visiblity of the second TextBlock to DetailsVisiblity property? <ListBox "{Binding Items}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Title}" /> <TextBlock Text="{Binding Details}" Visibility="{Binding ???}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

    Read the article

  • How to print each object in a collection in a separate page in Silverlight

    - by Ash
    I would like to know if its possible to print each object in a collection in separate pages using Silverlight printing API. Suppose I have a class Label public class Label { public string Address { get; set; } public string Country { get; set; } public string Name { get; set; } public string Town { get; set; } } I can use print API and print like this. private PrintDocument pd; private void PrintButton_Click(object sender, RoutedEventArgs e) { pd.Print("Test Print"); } private void pd_PrintPage(object sender, PrintPageEventArgs e) { Label labelToPrint = new Label() { Name = "Fake Name", Address = "Fake Address", Country = "Fake Country", Town = "Town" }; var printpage = new LabelPrint(); printpage.DataContext = new LabelPrintViewModel(labelToPrint); e.PageVisual = printpage; } LabelPrint Xaml <StackPanel x:Name="LayoutRoot" VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding Address}" /> <TextBlock Text="{Binding Town}" /> <TextBlock Text="{Binding Country}" /> </StackPanel> Now, say I've a collection of Label objects, List<Label> labels = new List<Label>() { labelToPrint, labelToPrint, labelToPrint, labelToPrint }; How can I print each object in the list in separate pages ? Thanks for any suggestions ..

    Read the article

  • How do you Bind to a ComboBox in a DataTemplate?

    - by discwiz
    I have a listbox that is bound to an observable collection of Audio (custom class). The Audio class has two properties, DisplayText (string) and a property called TarpIds (Observable Collection of Integer). I need to allow the user to change the TarpID in the combo box for each list item displayed and catch the selection change. I created a DataTemplate that styles the DisplayText property from the Audio object and adds a ComboBox to display the available TarpIDs for this audio (These are dynamic and unique to each Audio). The DisplayText works great, but I can not get the TarpIDs to display in the ComboBox. Here is what I have so far and thanks for any help. FYI I set the ItemSource at run time that binds the ListUploadAudio to the Observable Collection of Audio. <Border BorderBrush="Red" Background="WhiteSmoke" CornerRadius="8"> <Border.Resources> <DataTemplate x:Key="UploadLayout" DataType="Audio"> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding Path=DisplayText}" FontWeight="Bold" Foreground="Blue"> </TextBlock> <ComboBox x:Name="ListBoxTarpIDs" ItemsSource="{Binding Path=TarpIds}"> </ComboBox> </StackPanel> </DataTemplate> </Border.Resources> <ListBox x:Name="ListUploadAudio" BorderBrush="Transparent" Background="Transparent" Width="230" Margin="10" Height="200" IsSynchronizedWithCurrentItem="True" SelectionMode="Multiple" ItemTemplate="{DynamicResource UploadLayout}"> </ListBox> </Border>

    Read the article

  • Printing in Silverlight 4

    - by Number8
    Hello, We have an application structured roughly like this: <Grid x:Name="LayoutRoot"> <ScrollViewer> <Canvas x:Name="canvas"> <StackPanel> < Button /><Slider /><Button /></StackPanel> <custom:Blob /> <custom:Blob /> <custom:Blob /> </Canvas> </ScrollViewer> </Grid> Each Blob consists of 1 or more rectangles, lines, and text boxes; they are positioned anywhere on the canvas. If I print the document using the LayoutRoot: PrintDocument pd = new PrintDocument(); pd += (s, pe) => { pe.PageVisual = LayoutRoot; }; pd.Print("Blobs"); ... it is like a print-screen -- the scrollbars, the sliders, the blobs that are visible -- are printed. If I set PageVisual = canvas, nothing is printed. How can I get all the blob objects, and just those objects, to print? Do I need to copy them into another container, and give that container to PageVisual? Can I use a ViewBox to make sure they all fit on one page? Thanks for any pointers....

    Read the article

  • Should I be using Expression Blend to design really dynamic UIs?

    - by Robert Rossney
    My company's product is, at its core, a framework for developing metadata-driven UIs. I don't know how to characterize it less succinctly than that, and hope I won't need to for purposes of this question, but we'll see. I've been trying to come up to speed on WPF, and have been building UI prototypes here and there, and recently I decided to see if I could use Expression Blend to help with the design of these UIs. And I'm pretty mystified at this point. It appears to me as though Expresssion Blend is designed with the expectation that you already know all of the objects that are going to be present in the UI at design time. But our program generates these object dynamically at runtime. For instance, a data row might be presented in a horizontal StackPanel containing alternating TextBlocks (for captions) and TextBoxes (for data fields). The number of these objects depends on metadata about the number of columns in the data row. I can, pretty readily, write code that runs through a metadata record and populates a StackPanel dynamically, setting up the binding of all of the controls to properties in either the data or metadata. (A TextBox's Width might be bound to metadata, while its Text is bound to data.) But I can't even begin to figure out how to do something like this in Expression Blend. I can manually create all these controls, so that I have a set of controls that I can apply styles to and work out the visual design of the app, but it's really a pain to do this. I can write code that goes through my data model and emits XAML for all these controls, I suppose, and then copy and paste it. But I'm going to feel really stupid if it turns out there a way to do this sort of thing in Expression Blend and I've dropped back and punted because I'm too dim to figure out the right way to think of it. Is this enough information for someone to try formulating an answer?

    Read the article

  • Binding Listbox item source to a collection of collections in windows phone 7

    - by Tee
    Hi there, I am trying to bind a Listbox ItemSource to a collection of multiple Lists. i.e. List PersonCollection List Person List Collection Now I need to show items from both of these list. In wpf you could use HierarchicalDataTemplate i believe, but not sure how I can do it in windows phone 7. Tried with Blend and it generates the following data template. <DataTemplate x:Key="PersonDataTemplate"> <Grid> <StackPanel Margin="0,0,1,0" Orientation="Vertical" VerticalAlignment="Top"> <TextBlock Margin="0,0,1,0" TextWrapping="Wrap" Text="{Binding Person[0].Name}" d:LayoutOverrides="Width"/> <TextBlock Margin="0,0,1,0" TextWrapping="Wrap" Text="{Binding Collection[0].Total}" d:LayoutOverrides="Width"/> </StackPanel> </Grid> </DataTemplate> Is there another way I can do this? I have tried to set the DataContext of Textbox in DataTemplate to individual arrays but did not seem to work. Cant find anything similar on the net apart from the confirmation that HierarchicalDataTemplate is not supported in Windows Phone 7. I have other ways to do but none elegant.. Thanks in advance. Regards

    Read the article

  • Managing mandatory fields with triggers

    - by okkesemin
    I would like to set mandatory field backgrounds are red and others are green. So I try to implement below. But I could not set ValueConstraint Nullable property with trigger. Could you help please ? <Window x:Class="TriggerGirilmesigerekenalanlar.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:y="http://infragistics.com/Editors" Title="Window1" Height="300" Width="300"> <Window.Resources> <Style TargetType="{x:Type y:XamTextEditor}"> <Style.Triggers> <Trigger Property="ValueConstraint" Value="{x:Null}"> <Trigger.Setters> <Setter Property="Background" Value="green"></Setter> </Trigger.Setters> </Trigger> <Trigger Property="y:ValueConstraint.Nullable" Value="false"> <Trigger.Setters> <Setter Property="Background" Value="red"></Setter> </Trigger.Setters> </Trigger> </Style.Triggers> </Style> </Window.Resources> <StackPanel> <y:XamTextEditor> <y:XamTextEditor.ValueConstraint> <y:ValueConstraint Nullable="False" ></y:ValueConstraint> </y:XamTextEditor.ValueConstraint> </y:XamTextEditor> <y:XamTextEditor></y:XamTextEditor> </StackPanel> </Window>

    Read the article

  • Userdefined margins in WPF printing

    - by MTR
    Most printing samples for WPF go like this: PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { StackPanel myPanel = new StackPanel(); myPanel.Margin = new Thickness(15); Image myImage = new Image(); myImage.Width = dialog.PrintableAreaWidth; myImage.Stretch = Stretch.Uniform; myImage.Source = new BitmapImage(new Uri("pack://application:,,,/Images/picture.bmp")); myPanel.Children.Add(myImage); myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight)); myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize)); dialog.PrintVisual(myPanel, "A Great Image."); } What I don't like about this is, that they always set the margin to a fixed value. But in PrintDialog the user has the option to choose a individual margin that no sample cares about. If the user now selects a margin that is larger as the fixed margin set by program, the printout is truncated. Is there a way to get the user selected margin value from PrintDialog? TIA Michael

    Read the article

  • How to have a user control as a ListBoxItem

    - by Harry
    I want to bind a user control (View) to a ListBoxItem. The ListBox is bound to a collection of ViewModels. I have set the ListBox's ItemTemplate as so: <ListBox.ItemTemplate> <DataTemplate> <View:ContactView/> </DataTemplate> </ListBox.ItemTemplate> But all I get are blank ListBoxItems. I can click on them, but nothing is showing visually. My ContactView code is very simply: <Border> <DockPanel> <StackPanel DockPanel.Dock="Right" Orientation="Vertical"> <TextBlock Text="{Binding Path=ContactFirstName, FallbackValue=FirstName}" FontWeight="Bold" Margin="5, 0, 5, 0"></TextBlock> <TextBlock Text="{Binding Path=ContactLastName, FallbackValue=LastName}" FontWeight="Bold" Margin="5, 0, 5, 0"></TextBlock> <TextBlock Text="{Binding Path=ContactNumber, FallbackValue=Number}" Margin="5, 0, 5, 0"></TextBlock> </StackPanel> </DockPanel> </Border> What could be wrong with this? Thanks.

    Read the article

  • InputManager ignores cut/copy/paste when initiated from menu

    - by Wallstreet Programmer
    I'm using the InputManager to check if changes to controls are done by user or code. This works fine, except when user uses the context menu for cut/copy/paste. If the user do ctrl+v in a textbox, InputManager correctly notices it. However, if the paste is done from the context menu of the textbox, the InputManager never fires the PreNotifyInput or PostNotifyInput events. Anyone knows why? Or how to detect that these user actions? Below is a working sample. The lower textblock never gets updated when user uses the cut/copy/paste menu in the above textbox since PreNotifyInput never fires. XAML: <Window x:Class="InputMgrDemo.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300"> <StackPanel> <TextBox TextChanged="TextBox_TextChanged" /> <TextBlock Name="_text" /> </StackPanel> </Window> Code behind: using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace InputMgrDemo { public partial class Window1 : Window { public Window1() { InitializeComponent(); InputManager.Current.PreNotifyInput += ((sender, e) => _userInput = true); InputManager.Current.PostNotifyInput += ((sender, args) => _userInput = false); } private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { if (_userInput) { _text.Text = (sender as TextBox).Text; } } private bool _userInput; } }

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >