Search Results

Search found 9012 results on 361 pages for 'wpf binding'.

Page 21/361 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Can I change the binding source to another source in XAML?

    - by No hay Problema
    Hi guys, I want to do a very simple thing, can you point me on the right direction? I want to change the source in XAML to another object source, let me put you an example: I have a Listview, bound to a "Model A", it has many properties, but one is called "Total". This property is not shown on the View Each ListviewItem has its own source (ItemsSource), BUT, one of the fields should show "Total" from "Model A" Caveat: I am implementing MVVM, so the "Model A" is assigned as a VM DataSource, XAML knows nothing about it. So, in my perfect world the XAML should look like this: <GridViewColumn Header="Total" Width="150"> <GridViewColumn.CellTemplate> <DataTemplate> <Label Content="{Binding Source=<The source of LISTVIEW> Path=Total}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> I have tried RelativeSource but that points me to the XAML object, I want the source of it, is it possible? Thanks

    Read the article

  • How to refresh xmlDataProvider when xml document changes at runtime in WPF?

    - by Kajsa
    I am trying to make a image viewer/album creator in visual studio, wpf. The image paths for each album is stored in an xml document which i bind to to show the images from each album in a listbox. The problem is when i add a image or an album at runtime and write it to the xml document. I can't seem to make the bindings to the xml document update so they show the new images and albums aswell. Calling Refresh() on the XmlDataProvider doesn't change anything. I don't wish to redo the binding of the XmlDataProvider, just make it read from the same source again. XAML: ... <Grid.DataContext> <XmlDataProvider x:Name="Images" Source="Data/images.xml" XPath="/albums/album[@name='no album']/image" /> </Grid.DataContext> ... <Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="0" Margin="0,0,0,5" Content="{x:Static resx:Resource.AddImageLabel}"/> <TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Name="newImagePath" Margin="0" /> <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Name="newImagePathButton" Content="{x:Static resx:Resource.BrowseImageButton}" Click="newImagePathButton_Click" /> ... <ListBox Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="3" HorizontalAlignment="Stretch" Name="thumbnailList" VerticalAlignment="Bottom" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding BindingGroupName=Images}" SelectedIndex="0" Background="#FFE0E0E0" Height="110"> ... Code behind: private void newImagePathButton_Click(object sender, RoutedEventArgs e) { string imagePath = newImagePath.Text; albumCreator.addImage(imagePath, null); //Reset import image elements to default newImagePath.Text = ""; //Refresh thumbnail listbox Images.Refresh(); Console.WriteLine("Image added!"); } public void addImage(string source, XmlElement parent) { if (parent == null) { //Use default album parent = (XmlElement)root.FirstChild; } //Create image element with source element within XmlElement newImage = xmlDoc.CreateElement(null, "image", null); XmlElement newSource = xmlDoc.CreateElement(null, "source", null); newSource.InnerText = source; newImage.AppendChild(newSource); //Add image element to parent parent.AppendChild(newImage); xmlDoc.Save(xmlFile); } Thank you very much for any help!

    Read the article

  • Winforms - a strange problem a with simple binding

    - by Adi Barda
    Hi Guys, It's hard for me to clearly describe my problem but I'll try. I have a UserControl1 which contains UserControl2 which contains several WinForms controls (most of them DevExpress). I do simple binding to these controls to my datatable fields. So far everything works fine. When I move the focus to a record in the table (by navigating in a grid rows for example) the binding works great, the concurrenmcy manager moves the cursor and everything reflects right in the bounded controls. The problem starts when I add new user UserControl3 above UserControl2 and make UserControl2.Visible = false. Now UserControl3 is shown and UserControl2 exists but not shown. Now when I set UserControl2.Visible = true to show it again the simple binding stops working! I navigate in the grid but either the ConcurrencyManager stops working or the simple binding becomes disconnected. My question: Are there any known issues/ best practices with the binding & concurrency manager? Thanks a lot, Adi Barda

    Read the article

  • Changing the message (or exception) in WPF ValidatesOnException binding

    - by Emad
    I have a WPF application using MVVM. I am using binding to a POCO object. The Textbox is bound to a property in the object like: <TextBox.Text> <Binding Path="CertainProperty" Mode="TwoWay" > <Binding.ValidationRules> <ExceptionValidationRule/> </Binding.ValidationRules> </Binding> </TextBox.Text> Now this property is a a int property and when the user tried to enter a non-numeric value, they get the "input string was not in a correct format". What I need to do is customize this message to a more user friendly one. How can I do that ?

    Read the article

  • Element binding in Silverlight

    - by Matt
    Where can I find some good documentation on data/element binding? My Google searches haven't turned much up. I had a custom class with two properties named Text and Value. When I tried binding a list to a listbox it wouldn't work. By chance I modifed my datatemplate from this <TextBox Text="{Binding Text}"></TextBox> to this <TextBox Text="{Binding Path=Text}"></TextBox> and then everything worked great. I need some indepth documenation/samples to data/element binding. I don't understand why some examples have the path set whereas others do not. A full explanation of this, and all other nice to know tips would be much appreciated.

    Read the article

  • Swapping data binding in code

    - by Phil J Pearson
    I have two data-bound text boxes. One is bound to a string and the other to a number. The 'default' binding is set in XAML. Under some circumstances I need to reverse the bindings at runtime (the string is usually a prefix but sometimes it's a suffix). I have the following code in my view model, called when the window is loaded: Binding stringBinding = BindingOperations.GetBinding(view.seqLeft, TextBox.TextProperty); Binding numberBinding = BindingOperations.GetBinding(view.seqRight, TextBox.TextProperty); view.seqLeft.SetBinding(TextBlock.TextProperty, numberBinding); view.seqRight.SetBinding(TextBlock.TextProperty, stringBinding); After that the code loads the properties to which the binding refers. The problem is that the 'new' binding doesn't seem to work. What have I missed? Is there a better way?

    Read the article

  • Binding expression failing.

    - by Rohit Kandhal
    My output window is flooded with binding expression failures like : "Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.UserControl', AncestorLevel='1''. BindingExpression:Path=DataContext.CurrentActivationObjectType; DataItem=null; target element is 'StackPanel' (Name=''); target property is 'NoTarget' (type 'Object')" and similar binding issues. Also i found that these failure occurs only when the screen loads (i.e. first time) No failures there after. I've checked the binding it is fine . Binding :

    Read the article

  • How to disable maximize button in a WPF appication page not in a window

    - by Lukman
    I want to disable the maximize button in WPF application page, not in a WPF application window When I searched in Google, it is available methods for disabling the maximize button in WPF window The code snippet is as follows Window.WindowStyle= WindowStyle.None But is not working in WPF page It is showing errors. In WPF page there is WindowStyleProperty instead of WindowStyle and it is showing errors as Error 1:A static readonly field cannot be assigned to (except in a static constructor or a variable initializer) Error 2: Cannot implicitly convert type 'System.Windows.WindowStyle' to 'System.Windows.DependencyProperty' So how can I disable the maximize button in WPF page Then how can I implement it Suggest me any sample code snippet.... Advance thanks.........

    Read the article

  • WPF win app and browser app

    - by pdiddy
    I'm hearing this alot, that you can develop an app in WPF and run it as a desktop app or in a browser. Is this really true? I've install visual studio 2010 and I see 2 project templates : WPF Windows Application and WPF Browser Application (XBAP). Currently reading a book on WPF, it talks about Page-Base app, which can be use for navigation. To creatre an app to run on your browser you have to use the WPF Browser Application. So if I start with WPF Windows Application template can I run it in a browser ? I am assuming not since most of my class will be Window and not Page ....

    Read the article

  • What makes MVVM uniquely suited to WPF?

    - by Reed Copsey
    The Model-View-ViewModel is very popular with WPF and Silverlight. I've been using this for my most recent projects, and am a very large fan. I understand that it's a refinement of MVP. However, I am wondering exactly what unique characteristics of WPF (and Silverlight) allow MVVM to work, and prevent (or at least make difficult) this pattern from working using other frameworks or technologies. I know MVVM has a strong dependency on the powerful data binding technology within WPF. This is the one feature which many articles and blogs seem to mention as being the key to WPF providing the means of the strong separation of View from ViewModel. However, data binding exists in many forms in other UI frameworks. There are even projects like Truss that provide WPF-style databinding to POCO in .NET. What features, other than data binding, make WPF and Silverlight uniquely suited to Model-View-ViewModel?

    Read the article

  • WPF DataGrid: How to get Converter

    - by Nike
    I create DataGrid Columns with Binding (where i is a Int value): dataGrid.Columns.Add(new DataGridTextColumn { Header = i.ToString(), Binding = CreateBinding(i), }); private Binding CreateBinding(int num) { Binding bind = new Binding(string.Format("[{0}]", num)); bind.Converter = new CellValueConverter(); return bind; } In the CreateBinding method I have an access to bind.Converter property. I need to call Converter.Convert() method in some handler, but there is no Converter property when I try to access it: (dataGrid.Columns[clm] as DataGridTextColumn).Binding."no Converter property!" How can I get my CellValueConverter which was created for particular Column?

    Read the article

  • Where to find good 3d articles for wpf?

    - by Ankit Rathod
    Hello, I am beginner in WPF. I am basically a Silverlight guy and as i know it doesn't support the full real 3d model of WPF. I am getting interested in learning 3D in WPF. I googled up for WPF and i get very old links which are 3 years old back when WPF was known as Avalon. They may not be of any use in V4.0. Can anybody refer me some links where i can learn WPF 3D from basics? Thanks in advance :)

    Read the article

  • Bind Icon depending on Enum in WPF Treeview

    - by phenevo
    Hi, I have at treeeview TextBox, and I want convert my Enum: <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=AcceptationStatusGlobalFlag}" /> public enum AcceptationStatusGlobalFlag { NotReady = 0, Ready = 1, AcceptedByAdmin=2 } To Icons. There will be 3 icons, let say ready.jpg, notready.jpg and AcceptedByAdmin.jpg Country and Region has pool AcceptationStatusGlobalFlag and on both I want to display this enum/Icon <TreeView Name="structureTree" SelectedItemChanged="structureTree_SelectedItemChanged" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding}" Height="413" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible" Width="Auto" PreviewMouseRightButtonUp="structureTree_PreviewMouseRightButtonUp" FontFamily="Verdana" FontSize="12"> <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type ServiceMy:Country}" ItemsSource="{Binding Path=ListOfRegions}"> <StackPanel Orientation="Horizontal"> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=Name}"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" H:"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=NumberOfHotels}"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" "/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" FG:"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=AcceptationStatusGlobalFlag}" /> <!--<Button Name="BTNAddRegion" Height="20" Content="+" Click="BTNAddRegion_Click"></Button>--> </StackPanel> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type ServiceMy:Region}" ItemsSource="{Binding Path=ListOfProvinces}"> <StackPanel Orientation="Horizontal"> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=Name}"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" H:"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=NumberOfHotels}"/> <TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" "/> <!--<Button Name="BTNAddProvince" Height="20" Content="+" Click="BTNAddProvince_Click"></Button>--> </StackPanel> </DataTemplate> </TreeView.Resources> </TreeView> </GroupBox> </StackPanel> </Grid>

    Read the article

  • WPF How to bind to a specific element in the Collection

    - by PaN1C_Showt1Me
    Hi, I want to make a binding to a specific element in the Collection. But I cannot figure out how to write the Binding. This is the code: public class MySource { .. public string SomeProp; public ICollection<T> MyCollection; .. } this.DataContext = new MySource(); <TextBox Text={Binding SomeProp} /> <TextBox Text={Binding FIRST_ELEMENT_OF_THE_MyCollection} /> <TextBox Text={Binding SECOND_ELEMENT_OF_THE_MyCollection} /> <!--Ignore other elements--> Try to replace those binding strings, please Thank you

    Read the article

  • Binding "Text-Property" of a derived textbox to another textbox doesn´t work

    - by Jehof
    Hello, i have a class 'MyTextBox' that derives from the default TextBox in Silverlight. This class currently contains no additional code. I set up a binding in xaml to bind the Text-Property of MyTextbox to another Textbox to reflect the input made in the Textbox. The effect is that MyTextBox doesn´t update and not display the text of the other Textbox. Additional i made an equal binding for a normal Textbox. And this works. Here´s the XAML for the bindings. <UserControl x:Class="Silverlight.Sample.Dummy" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:my="clr-namespace:Sample" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <StackPanel x:Name="LayoutRoot" Background="White"> <TextBox Height="23" x:Name="textBox2" Width="120" /> <TextBox Text="{Binding ElementName=textBox2, Path=Text, Mode=TwoWay}" Width="120" /> <my:NumberTextBox Width="120" Text="{Binding ElementName=textBox2, Path=Text, Mode=OneWay}" /> </StackPanel> Is there something special to set for binding, when i derive from a control. PS: I tried a binding to a dummy object with INotifyPropertyChanged and set it as DataContext for the existing Textboxes. This test works as expected and my derived textbox gets updated.

    Read the article

  • WPF Databinding- Not your fathers databinding Part 1-3

    - by Shervin Shakibi
    As Promised here is my advanced databinding presentation from South Florida Code camp and also Orlando Code camp. you can find the demo files here. http://ssccinc.com/wpfdatabinding.zip Here is a quick description of the first demos, there will be 2 other Blogposting in the next few days getting into more advance databinding topics.   Example00 Here we have 3 textboxes, The first textbox mySourceElement Second textbox has a binding to mySourceElement and Path= Text <Binding ElementName="mySourceElement" Path="Text"  />   Third textbox is also bound to the Text property but we use inline Binding <TextBlock Text="{Binding ElementName=mySourceElement,Path=Text }" Grid.Row="2" /> Here is the entire XAML     <Grid  >           <Grid.RowDefinitions >             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />         </Grid.RowDefinitions>         <TextBox Name="mySourceElement" Grid.Row="0"                  TextChanged="mySourceElement_TextChanged">Hello Orlnado</TextBox>         <TextBlock Grid.Row="1">                        <TextBlock.Text>                 <Binding ElementName="mySourceElement" Path="Text"  />             </TextBlock.Text>         </TextBlock>         <TextBlock Text="{Binding ElementName=mySourceElement,Path=Text }" Grid.Row="2" />     </Grid> </Window> Example01 we have a slider control, then we have two textboxes bound to the value property of the slider. one has its text property bound, the second has its fontsize property bound. <Grid>      <Grid.RowDefinitions >          <RowDefinition Height="40px" />          <RowDefinition Height="40px" />          <RowDefinition Height="*" />      </Grid.RowDefinitions>      <Slider Name="fontSizeSlider" Minimum="5" Maximum="100"              Value="10" Grid.Row="0" />      <TextBox Name="SizeTextBox"                    Text="{Binding ElementName=fontSizeSlider, Path=Value}" Grid.Row="1"/>      <TextBlock Text="Example 01"                 FontSize="{Binding ElementName=SizeTextBox,  Path=Text}"  Grid.Row="2"/> </Grid> Example02 very much like the previous example but it also has a font dropdown <Grid>      <Grid.RowDefinitions >          <RowDefinition Height="20px" />          <RowDefinition Height="40px" />          <RowDefinition Height="40px" />          <RowDefinition Height="*" />      </Grid.RowDefinitions>      <ComboBox Name="FontNameList" SelectedIndex="0" Grid.Row="0">          <ComboBoxItem Content="Arial" />          <ComboBoxItem Content="Calibri" />          <ComboBoxItem Content="Times New Roman" />          <ComboBoxItem Content="Verdana" />      </ComboBox>      <Slider Name="fontSizeSlider" Minimum="5" Maximum="100" Value="10" Grid.Row="1" />      <TextBox Name="SizeTextBox"      Text="{Binding ElementName=fontSizeSlider, Path=Value}" Grid.Row="2"/>      <TextBlock Text="Example 01" FontFamily="{Binding ElementName=FontNameList, Path=Text}"                 FontSize="{Binding ElementName=SizeTextBox,  Path=Text}"  Grid.Row="3"/> </Grid> Example03 In this example we bind to an object Employee.cs Notice we added a directive to our xaml which is clr-namespace and the namespace for our employee Class xmlns:local="clr-namespace:Example03" In Our windows Resources we create an instance of our object <Window.Resources>     <local:Employee x:Key="MyEmployee" EmployeeNumber="145"                     FirstName="John"                     LastName="Doe"                     Department="Product Development"                     Title="QA Manager" /> </Window.Resources> then we bind our container to the that instance of the data <Grid DataContext="{StaticResource MyEmployee}">         <Grid.RowDefinitions>             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />         </Grid.RowDefinitions>         <Grid.ColumnDefinitions >             <ColumnDefinition Width="130px" />             <ColumnDefinition Width="178*" />         </Grid.ColumnDefinitions>     </Grid> and Finally we have textboxes that will bind to that textbox         <Label Grid.Row="0" Grid.Column="0">Employee Number</Label>         <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=EmployeeNumber}"></TextBox>         <Label Grid.Row="1" Grid.Column="0">First Name</Label>         <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=FirstName}"></TextBox>         <Label Grid.Row="2" Grid.Column="0">Last Name</Label>         <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=LastName}" />         <Label Grid.Row="3" Grid.Column="0">Title</Label>         <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=Title}"></TextBox>         <Label Grid.Row="4" Grid.Column="0">Department</Label>         <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=Department}" />

    Read the article

  • WPF dynamic layout: how to enforce square proportions (width equals height)?

    - by Gart
    I'm learning WPF and can't figure out how to enfore my buttons to take a square shape. Here is my XAML Markup: <Window x:Class="Example" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="368" Width="333"> <Window.Resources> <Style x:Key="ToggleStyle" BasedOn="{StaticResource {x:Type ToggleButton}}" TargetType="{x:Type RadioButton}"> </Style> </Window.Resources> <RadioButton Style="{StaticResource ToggleStyle}"> Very very long text </RadioButton> </Window> Specifying explicit values for Width and Height attributes seems like a wrong idea - the button should calculate its dimensions based on its contents automagically, but keep its width and height equal. Is this possible?

    Read the article

  • How to disable border of WPF button when click it?

    - by Ekkapop
    How to disable border of WPF button when I click it? I have create button like below, everything work fine except when I click on the button. <Button Background="Transparent" BorderBrush="Transparent"> <Button.Content> <StackPanel> <Image Source="xxx.png" /> <TextBlock Text="Change Password" /> </StackPanel> </Button.Content> </Button> When I click the button, it has border like below. I try to create style for FocusVisualStyle of the button but it don't work as I expect, this problem also occur when I set IsDefault="True" too.

    Read the article

  • Wpf datagrid row not updating when binded collection updated?

    - by RAJ K
    I have product class class Products { public int ProductID { get; set; } public int Quantity { get; set; } public string Description { get; set; } public decimal Price { get; set; } public decimal SubTotal { get; set; } } public List<Products> ProductsList = new List<Products>(); I have binded this "ProductList" to wpf datagrid. This datagrid shows item already in collection (before DataGrid.DataContext applied) but not showing new item added. I am using List< instead of ObservableCollection< because I want to update items if user changes quantity. I don't know how to do that using ObservableCollection<. Some code will help thanks

    Read the article

  • How can I make a grid of clickable images from a list of data in WPF?

    - by mico
    Hello, I am a seasoned C and Java programmer, but an absolute WPF newbie. I am creating a kiosk application that will display a list of images of products that the user will click to see product details and maybe place an order. I am trying to structure my app with MVVM Foundation because I am used to the benefits of structure and tests. I wonder what is the most natural way to create a grid of clickable images that will fill the screen left to right, top to bottom (or the other way round, I have no exact requirements). Any image should be bound to an object that will become current and be displayed in the next screen. Thanks for your help.

    Read the article

  • WPF: "Items collection must be empty before using ItemsSource."

    - by Zack Peterson
    I'm trying to get images to display in a WPF ListView styled like a WrapPanel as described in this old ATC Avalon Team article: How to Create a Custom View. When I try to populate the ListView with a LINQ-to-Entities queried collection of ADO.NET Entity Framework objects I get the following exception: Exception Items collection must be empty before using ItemsSource. My code… Visual Basic Private Sub Window1_Loaded(...) Handles MyBase.Loaded ListViewImages.ItemsSource = From g In db.Graphic _ Order By g.DateAdded Ascending _ Select g End Sub XAML <ListView Name="ListViewImages" SelectionMode="Single" ItemsSource="{Binding}"> <local:ImageView /> </ListView> I put a breakpoint on that line. ListViewImages.ItemsSource is Nothing just before the LINQ assignment.

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >