Search Results

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

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

  • [WPF] ComboBox.Text not taking the ItemStringFormat property into account

    - by Thomas Levesque
    I just noticed a strange behavior which looks like a bug. Consider the following XAML : <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"> <Page.Resources> <x:Array x:Key="data" Type="{x:Type sys:String}"> <sys:String>Foo</sys:String> <sys:String>Bar</sys:String> <sys:String>Baz</sys:String> </x:Array> </Page.Resources> <StackPanel Orientation="Vertical"> <Button>Boo</Button> <ComboBox Name="combo" ItemsSource="{Binding Source={StaticResource data}}" ItemStringFormat="##{0}##" /> <TextBlock Text="{Binding Text, ElementName=combo}"/> </StackPanel> </Page> The ComboBox displays the values as "##Foo##", "##Bar##" and "##Baz##". But the TextBlock displays the selected values as "Foo", "Bar" and "Baz". So the ItemStringFormat is apparently ignored for the Text property... Is that a bug ? If it is, is there a workaround ? Or am I just doing something wrong ?

    Read the article

  • WPF zoom canvas and maintain scroll position

    - by Alex McBride
    I have a Canvas element, contained within a ScrollViewer, which I'm zooming using ScaleTransform. However, I want to be able to keep the scroll position of the viewer focused on the same part of the canvas after the zoom operation has finished. Currently when I zoom the canvas the scroll position of the viewer stays where it was and the place the user was viewing is lost. I'm still learning WPF, and I've been going backwards and forwards a bit on this, but I can't figure out a nice XAML based way to accomplish what I want. Any help in this matter would be greatly appreciated and would aid me in my learning process. Here is the kind of code I'm using... <Grid> <ScrollViewer Name="TrackScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <Canvas Width="2560" Height="2560" Name="TrackCanvas"> <Canvas.LayoutTransform> <ScaleTransform ScaleX="{Binding ElementName=ZoomSlider, Path=Value}" ScaleY="{Binding ElementName=ZoomSlider, Path=Value}"/> </Canvas.LayoutTransform> <!-- Some complex geometry describing a motor racing circuit --> </Canvas> </ScrollViewer> <StackPanel Orientation="Horizontal" Margin="8" VerticalAlignment="Top" HorizontalAlignment="Left"> <Slider Name="ZoomSlider" Width="80" Minimum="0.1" Maximum="10" Value="1"/> <TextBlock Margin="4,0,0,0" VerticalAlignment="Center" Text="{Binding ElementName=ZoomSlider, Path=Value, StringFormat=F1}"/> </StackPanel> </Grid>

    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

  • Handle exceptions with WPF and MVVM

    - by Jon Cahill
    I am attempting to build an application using WPF and the MVVM pattern. I have my Views being populated from my ViewModel purely through databinding. I want to have a central place to handle all exceptions which occur in my application so I can notify the user and log the error appropriately. I know about Dispatcher.UnhandledException but this does not do the job as exception that occur during databinding are logged to the output windows. Because my View is databound to my ViewModel the entire application is pretty much controlled via databinding so I have no way to log my errors. Is there a way to generically handle the exceptions raised during databinding, without having to put try blocks around all my ViewModel public's? Example View: <Window x:Class="Test.TestView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="TestView" Height="600" Width="800" WindowStartupLocation="CenterScreen"> <Window.Resources> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> </Window.Resources> <StackPanel VerticalAlignment="Center"> <Label Visibility="{Binding DisplayLabel, Converter={StaticResource BooleanToVisibilityConverter}}">My Label</Label> </StackPanel> </Window> The ViewModel: public class TestViewModel { public bool DisplayLabel { get { throw new NotImplementedException(); } } } It is an internal application so I do not want to use Wer as I have seen previously recommended.

    Read the article

  • Wpf combobox selection change breaks Datatrigger

    - by biju
    Hi, I am trying to set the selected value of a combobox from a style trigger.It works as long as we dont manually change any value in the combobox.But it stops working altogether after manually changing the selection.How can i solve this.A sample code is attached.Please do help <Window x:Class="InputGesture.Window2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:InputGesture" Title="Window2" Height="300" Width="300" Name="Sample"> <Window.Resources> <Style TargetType="{x:Type ComboBox}"> <Setter Property="ComboBox.SelectedValue" Value="1"/> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=chk,Path=IsChecked}" Value="True"> <Setter Property="ComboBox.IsEnabled" Value="False"/> <Setter Property="ComboBox.SelectedValue" Value="2"/> </DataTrigger> </Style.Triggers> </Style> </Window.Resources> <StackPanel> <CheckBox Name="chk" Height="23"/> <ComboBox Name="cmb" Height="23" DisplayMemberPath="Name" SelectedValuePath="Id" ItemsSource="{Binding ElementName=Sample,Path=DT}"> </ComboBox> <Button Height="23" Click="Button_Click"/> </StackPanel> </Window>

    Read the article

  • WPF DatePicker IsEnabled property not changing appearance

    - by Jonathan
    I think I have found an issue with the DatePicker in the toolkit, perhaps some of you gurus can check it out. The issue is when setting the IsEnabled property of the DatePicker. If set in XAML, it stays grey even if you set the IsEnabled to true at run time. The same goes for the other way around should it start off being enabled. The button just changes the IsEnabled property of the date picker, you will see that when it becomes enabled, the style remains grayed out. <Window x:Class="WpfApplication3.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit" Title="Window1" Height="300" Width="300"> <StackPanel> <tk:DatePicker x:Name="txtDate" IsEnabled="False"></tk:DatePicker> <Button Height="25" Click="Button_Click"></Button> </StackPanel> </Window> private void Button_Click(object sender, RoutedEventArgs e) { txtDate.IsEnabled = !txtDate.IsEnabled; }

    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

  • silverlight master-detail with two listboxes in pure xaml with ria services throwing exception

    - by Sam
    Hi, I was trying to achieve master-detail with 2 ListBox, 2 DomainDataSource and a IValueConverter, when entering the page it throws the random error it does when your xaml is invalid: "AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 24 Position: 61]" Which is in fact the start position of where I am binding the listbox selected item with converter to the parameter's value of my DomainDataSource. I would love to achieve this by pure xaml, I did it by code behind and that works but I don't like it :p When the parameter is a hard-coded integer 1, it works, so I assume it's the value binding My code is below here, thanks in advance for at least looking :) (taken into accound all the xmlns's & usings are correct) Xaml: <Grid x:Name="LayoutRoot"> <Grid.Resources> <helpers:ListItemtoIdListValueConverter x:Key="mListConverter" /> </Grid.Resources> <riacontrols:DomainDataSource x:Name="GetLists" DomainContext="{StaticResource DbContext}" LoadSize="20" QueryName="GetLists" AutoLoad="True" /> <riacontrols:DomainDataSource x:Name="GetListItems" DomainContext="{StaticResource DbContext}" LoadSize="20" QueryName="GetListItemsById" AutoLoad="True"> <riacontrols:DomainDataSource.QueryParameters> <riadata:Parameter ParameterName="id" Value="{Binding ElementName=ListBoxLists, Path=SelectedItem, Converter={StaticResource mListConverter}}" /> </riacontrols:DomainDataSource.QueryParameters> </riacontrols:DomainDataSource> <activity:Activity IsActive="{Binding IsBusy, ElementName=ListBoxListItems}"> <StackPanel Orientation="Horizontal"> <ListBox x:Name="ListBoxLists" ItemsSource="{Binding Data, ElementName=GetLists, Mode=OneWay}" Width="150" Margin="0,0,10,10" /> <ListBox x:Name="ListBoxListItems" ItemsSource="{Binding Data, ElementName=GetListItems, Mode=OneWay}" Width="150" Margin="0,0,10,10" /> </StackPanel> </activity:Activity> </Grid> IValueConverter: public class ListItemtoIdListValueConverter: IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { list mList = (list)value; if (mList != null) return mList.id; else return null; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion }

    Read the article

  • Silverlight ComboBox Attached Behavior

    - by Mark Cooper
    I am trying to create an attached behavior that can be applied to a Silverlight ComboBox. My behavior is this: using System.Windows.Controls; using System.Windows; using System.Windows.Controls.Primitives; namespace AttachedBehaviours { public class ConfirmChangeBehaviour { public static bool GetConfirmChange(Selector cmb) { return (bool)cmb.GetValue(ConfirmChangeProperty); } public static void SetConfirmChange(Selector cmb, bool value) { cmb.SetValue(ConfirmChangeProperty, value); } public static readonly DependencyProperty ConfirmChangeProperty = DependencyProperty.RegisterAttached("ConfirmChange", typeof(bool), typeof(Selector), new PropertyMetadata(true, ConfirmChangeChanged)); public static void ConfirmChangeChanged(DependencyObject d, DependencyPropertyChangedEventArgs args) { Selector instance = d as Selector; if (args.NewValue is bool == false) return; if ((bool)args.NewValue) instance.SelectionChanged += OnSelectorSelectionChanged; else instance.SelectionChanged -= OnSelectorSelectionChanged; } static void OnSelectorSelectionChanged(object sender, RoutedEventArgs e) { Selector item = e.OriginalSource as Selector; MessageBox.Show("Unsaved changes. Are you sure you want to change teams?"); } } } This is used in XAML as this: <UserControl x:Class="AttachedBehaviours.MainPage" 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:this="clr-namespace:AttachedBehaviours" mc:Ignorable="d"> <Grid x:Name="LayoutRoot"> <StackPanel> <ComboBox ItemsSource="{Binding Teams}" this:ConfirmChangeBehaviour.ConfirmChange="true" > </ComboBox> </StackPanel> </Grid> </UserControl> I am getting an error: Unknown attribute ConfirmChangeBehaviour.ConfirmChange on element ComboBox. [Line: 13 Position: 65] Intellisense is picking up the behavior, why is this failing at runtime? Thanks, Mark EDIT: Register() changed to RegisterAttached(). Same error appears.

    Read the article

  • C# WPF XAML binding to DataTable

    - 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

  • Binding XML in Sliverlight without Nominal Classes

    - by AnthonyWJones
    Lets say I have a simple chunck of XML:- <root> <item forename="Fred" surname="Flintstone" /> <item forename="Barney" surname="Rubble" /> </root> Having fetched this XML in Silverlight I would like to bind it with xaml of this ilke:- <ListBox x:Name="ItemList" Style="{StaticResource Items}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Forename}" /> <TextBox Text="{Binding Surname}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Now I can bind simply enough with LINQ to XML and a nominal class:- public class Person { public string Forename {get; set;} public string Surname {get; set;} } So here is the question, can it be done without this class? IOW coupling between the Sliverlight code and the input XML is limited to the XAML only, other source code is agnostic to the set of attributes on the item element. Edit: The use of XSD is suggested but ultimately it amounts the same thing. XSD-Generated class. Edit: An anonymous class doesn't work, Silverlight can't bind them. Edit: This needs to be two way, the user needs to be able to edit the values and these value end up in the XML. (Changed original TextBlock to TextBox in sample above).

    Read the article

  • Silverlight combobox performance issue

    - by Vinzz
    Hi, I'm facing a performance issue with a crowded combobox (5000 items). Rendering of the drop down list is really slow (as if it was computing all items before showing any). Do you have any trick to make this dropdown display lazy? Xaml code: <Grid x:Name="LayoutRoot"> <StackPanel Orientation="Horizontal" Width="200" Height="20"> <TextBlock>Test Combo </TextBlock> <ComboBox x:Name="fooCombo" Margin="5,0,0,0"></ComboBox> </StackPanel> </Grid> code behind: public MainPage() { InitializeComponent(); List<string> li = new List<string>(); int Max = 5000; for (int i = 0; i < Max; ++i) li.Add("Item - " + i); fooCombo.ItemsSource = li; }

    Read the article

  • Why isn't my WPF Datagrid showing data?

    - by Edward Tanguay
    This walkthrough says you can create a WPF datagrid in one line but doesn't give a full example. So I created an example using a generic list and connected it to the WPF datagrid, but it doesn't show any data. What do I need to change on the code below to get it to show data in the datagrid? ANSWER: This code works now: XAML: <Window x:Class="TestDatagrid345.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:local="clr-namespace:TestDatagrid345" Title="Window1" Height="300" Width="300" Loaded="Window_Loaded"> <StackPanel> <toolkit:DataGrid ItemsSource="{Binding}"/> </StackPanel> </Window> Code Behind: using System.Collections.Generic; using System.Windows; namespace TestDatagrid345 { public partial class Window1 : Window { private List<Customer> _customers = new List<Customer>(); public List<Customer> Customers { get { return _customers; }} public Window1() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { DataContext = Customers; Customers.Add(new Customer { FirstName = "Tom", LastName = "Jones" }); Customers.Add(new Customer { FirstName = "Joe", LastName = "Thompson" }); Customers.Add(new Customer { FirstName = "Jill", LastName = "Smith" }); } } }

    Read the article

  • Bind a subclass to property

    - by Neir0
    Hi i have a simple question. Ofcourse it has many answers but i cannt choose right keywords to google. How i can bind a subclass to my wpf control? for example: It's my class. public class SiteFieldInfo<T> { public string Name { get; set; } public T Value { get; set; } public List<string> PositiveXPathExpressions { get; set; } public List<string> NegativeXPathExpressions { get; set; } } public class SiteInfo { public SiteFieldInfo<string> Author { get; set; } public SiteFieldInfo<DateTime> Date { get; set; } public SiteFieldInfo<string> Source { get; set; } } And i want to bind property Value from SiteFieldInfo to Text property of TextBox control. c# code: stackPanel1.DataContext = SiteInfoInstance; xaml code: <StackPanel Name="stackPanel1"> <TextBlock Text="Author" Grid.Row="0" Grid.Column="0" /> <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Author.Value}" /> </StackPanel> It's not working. What is right syntax or any alternatives?

    Read the article

  • WPF TextBox Interceping RoutedUICommands

    - by Joseph Sturtevant
    I am trying to get Undo/Redo keyboard shortcuts working in my WPF application (I have my own custom functionality implemented using the Command Pattern). It seems, however, that the TextBox control is intercepting my "Undo" RoutedUICommand. What is the simplest way to disable this so that I can catch Ctrl+Z at the root of my UI tree? I would like to avoid putting a ton of code/XAML into each TextBox in my application if possible. The following briefly demonstrates the problem: <Window x:Class="InputBindingSample.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="clr-namespace:InputBindingSample" Title="Window1" Height="300" Width="300"> <Window.CommandBindings> <CommandBinding Command="loc:Window1.MyUndo" Executed="MyUndo_Executed" /> </Window.CommandBindings> <DockPanel LastChildFill="True"> <StackPanel> <Button Content="Ctrl+Z Works If Focus Is Here" /> <TextBox Text="Ctrl+Z Doesn't Work If Focus Is Here" /> </StackPanel> </DockPanel> </Window> using System.Windows; using System.Windows.Input; namespace InputBindingSample { public partial class Window1 { public static readonly RoutedUICommand MyUndo = new RoutedUICommand("MyUndo", "MyUndo", typeof(Window1), new InputGestureCollection(new[] { new KeyGesture(Key.Z, ModifierKeys.Control) })); public Window1() { InitializeComponent(); } private void MyUndo_Executed(object sender, ExecutedRoutedEventArgs e) { MessageBox.Show("MyUndo!"); } } }

    Read the article

  • WPF binding fails with custom add and remove accessors for INotifyPropertyChanged.PropertyChanged

    - by emddudley
    I have a scenario which is causing strange behavior with WPF data binding and INotifyPropertyChanged. I want a private member of the data binding source to handle the INotifyPropertyChanged.PropertyChanged event. I get some exceptions which haven't helped me debug, even when I have "Enable .NET Framework source stepping" checked in Visual Studio's options: A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll A first chance exception of type 'System.InvalidOperationException' occurred in PresentationCore.dll Here's the source code: XAML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="TestApplication.MainWindow" DataContext="{Binding RelativeSource={RelativeSource Self}}" Height="100" Width="100"> <StackPanel> <CheckBox IsChecked="{Binding Path=CheckboxIsChecked}" Content="A" /> <CheckBox IsChecked="{Binding Path=CheckboxIsChecked}" Content="B" /> </StackPanel> </Window> Normal implementation works public partial class MainWindow : Window, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public bool CheckboxIsChecked { get { return this.mCheckboxIsChecked; } set { this.mCheckboxIsChecked = value; PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs("CheckboxIsChecked")); } } private bool mCheckboxIsChecked = false; public MainWindow() { InitializeComponent(); } } Desired implementation doesn't work public partial class MainWindow : Window, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged { add { lock (this.mHandler) { this.mHandler.PropertyChanged += value; } } remove { lock (this.mHandler) { this.mHandler.PropertyChanged -= value; } } } public bool CheckboxIsChecked { get { return this.mHandler.CheckboxIsChecked; } set { this.mHandler.CheckboxIsChecked = value; } } private HandlesPropertyChangeEvents mHandler = new HandlesPropertyChangeEvents(); public MainWindow() { InitializeComponent(); } public class HandlesPropertyChangeEvents : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public bool CheckboxIsChecked { get { return this.mCheckboxIsChecked; } set { this.mCheckboxIsChecked = value; PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs("CheckboxIsChecked")); } } private bool mCheckboxIsChecked = false; } }

    Read the article

  • Binding to TreeView in WPF

    - by KrisTrip
    I am trying to bind some data from a class instance to a TreeView. My code is as follows: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Parent myClass = new Parent(); this.DataContext = myClass; } } public class Parent { public String Name; public List<string> Children = new List<string>(); private static int count = 0; public Parent() { this.Name = "Test"; for (int i = 0; i < 10; i++) { Children.Add(i.ToString()); } } } And the XAML: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="clr-namespace:WpfApplication1" Title="MainWindow" Height="287" Width="525"> <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch"> <TreeView Name="TreeView" ItemsSource="{Binding}"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Children}"> <TextBlock Text="{Binding Name}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> </StackPanel> </Window> Nothing shows up in my TreeView. What am I doing wrong?

    Read the article

  • Why does my DataTemplate break the WPF designer?

    - by PRINCESS FLUFF
    Why does the DataTemplate line break the WPF designer in Visual Studio 2008? The program compiles and runs properly. The DataTemplate is applied as it should. However the entire DataTemplate block of code is underlined in red, and when I simply "build" the program without running, I get the error "Type reference cannot find public type named 'Character'" How come it can't find it in the designer yet the program applies the template properly? <UserControl x:Class="WPF_Tests.Tests.TwoCollecViews.TwoViews" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:DetailsPane="clr-namespace:WPF_Tests.Tests.DetailsPane" > <UserControl.Resources> <DataTemplate DataType="{x:Type DetailsPane:Character}"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Name}"></TextBlock> </StackPanel> </DataTemplate> </UserControl.Resources> <Grid> <ListBox ItemsSource="{Binding Path=Characters}" /> </Grid> </UserControl> EDIT: I am being told that this may be a bug in Visual Studio 2008, as it worked correctly in 2010. You can download the code here: http://www.mediafire.com/?z1myytvwm4n - The Test/TwoCollec xaml file's designer will break with this code.

    Read the article

  • WPF Image change source when button is disabled

    - by Taylor
    Hi, I'm trying to show a different image when the button is disabled. Should be easy with triggers, right?! For some reason, I have not been able to get the images to switch. I've tried setting triggers on both the image and button. What is wrong with what I have below? How can I change the image source when the button is enabled/disabled? Thanks! <Button x:Name="rleft" Command="{Binding Path=Operation}" CommandParameter="{x:Static vm:Ops.OpA}"> <Button.Content> <StackPanel> <Image Width="24" Height="24" RenderOptions.BitmapScalingMode="NearestNeighbor" SnapsToDevicePixels="True" Source="/MyAssembly;component/images/enabled.png"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=rleft, Path=Button.IsEnabled}" Value="False"> <Setter Property="Image.Source" Value="/MyAssembly;component/images/disabled.png" /> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> </StackPanel> </Button.Content> </Button>

    Read the article

  • DataGridComboBoxColumn was not found

    - by Budda
    The System.Windows.Controls.Data.DataGrid is used in my Silverlight application, but on attempt to add 'DataGridComboBoxColumn' column to the grid the following error messages are obtained: Error 1 The tag 'DataGridComboBoxColumn' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data'. C:\Project\Budda\VFMElita\VfmElitaView\Pages\SquadView.xaml 140 22 VfmElitaView Error 2 The type 'data:DataGridComboBoxColumn' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. C:\Project\Budda\VFMElita\VfmElitaView\Pages\SquadView.xaml 142 22 VfmElitaView Here is my "header" of the xaml-file: Here is grid: <StackPanel Grid.Row="1" Grid.Column="0" Grid.RowSpan="2"> <TextBlock Text="????"/> <data:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding FieldPlayers}"> <data:DataGrid.Columns> <!--<data:DataGridTemplateColumn Header="#"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Margin="4" Loaded="TextBlock_Loaded"/> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn>--> <data:DataGridTextColumn Header="?" Binding="{Binding Number}"/> <data:DataGridComboBoxColumn> - that doesn't work </data:DataGridComboBoxColumn> </data:DataGrid.Columns> </data:DataGrid> </StackPanel> What is required to get 'DataGridComboBoxColumn' workable? Any help is welcome. Thanks.

    Read the article

  • Changing label content programmatically from within a DataTemplate used in a DataGrid column header

    - by iimpact
    I'm dynamically creating DataGrid columns (based on an event from my ViewModel) and programmatically adding them to an existing DataGrid. Each column uses a generic HeaderTemplate by setting it to a DataTemplate that has been identified in the xaml. The DataTemplate contains two labels in which needs their content needs to be changed upon creation of the DataGrid column. How would this be done? I understand that the DataTemplate uses the ContentPresenter but I am having trouble accessing it within a dynamically created DataGrid column. Code is as follows: xaml: (template used to format the DataGrid column header): <DataTemplate x:Key="columnTemplate"> <StackPanel> <Label Padding="0" Name="labelA"/> <Separator HorizontalAlignment="Stretch"/> <Label Padding="0" Name="labelB"/> </StackPanel> </DataTemplate> c#: (used to dynamically create a DataGrid column and add it to an existing DataGrid) var dataTemplate = FindResource("columnTemplate") as DataTemplate; var column = new DataGridTextColumn(); column.HeaderTemplate = dataTemplate; DataGrid1.Columns.Add(column); I would like to then access both labelA and labelB and change the content.

    Read the article

  • Silverlight databinding error

    - by Petezah
    I found an example online that explains how to perform databinding to a ListBox control using LINQ in WPF. The example works fine but when I replicate the same code in Silverlight it doesn't work. Is there a fundamental difference between Silverlight and WPF that I'm not aware of? Here is an Example of the XAML: <ListBox x:Name="listBox1"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" FontSize="18"/> <TextBlock Text="{Binding Role}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Here is an example of my code behind: private void UserControl_Loaded(object sender, RoutedEventArgs e) { string[] names = new string[] { "Captain Avatar", "Derek Wildstar", "Queen Starsha" }; string[] roles = new string[] { "Hero", "Captain", "Queen of Iscandar" }; listBox1.ItemSource = from n in names from r in roles select new { Name = n, Role = r} }

    Read the article

  • Binding a WPF ComboBox to a different ItemsSource within a ListBox DataTemplate

    - by tjans
    I have a ListBox that contains a textbox and a combobox in its datatemplate: <ListBox Height="147" Margin="158,29,170,0" Name="PitcherListBox" VerticalAlignment="Top" ItemsSource="{Binding SomeCollectionOfObjects}" Background="Black"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Path=Name}" /> <ComboBox ItemsSource="{Binding LocalArrayOfIntsProperty}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> I want to bind the listbox to a collection of objects (which I've done successfully), but I want the combobox in the above datatemplate to have its itemssource set to a local property on the window (array of ints). I still want the combobox to have a two-way bind between its selected item and a property on the collection of objects... I have the following in code: PitcherListBox.DataContext = this; Basically in the end, I want the combobox within the listbox to have a different itemssource than the listbox itself. I can't seem to figure out how to change the ComboBox's ItemsSource in XAML. Can someone provide me some feedback? Thanks!

    Read the article

  • Silverlight ValidationSummary screen real estate

    - by Mark Cooper
    Silverlight 3; I have a ValidationSummary in the top row of my grid. When the ValidationSummary appears, it pushes my button row (row 3) off the bottom of the displayable screen. <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="36" /> </Grid.RowDefinitions> <di:ValidationSummary Grid.Row="0" /> <Grid x:Name="gridOuterContentHolder" Grid.Row="1"> <Grid.RowDefinitions> <RowDefinition Height="0.68*" /> <RowDefinition Height="5" /> <RowDefinition Height="0.32*" /> </Grid.RowDefinitions> <!-- elements removed for brevity --> </Grid> <StackPanel x:Name="stack" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"> <Button Content="Delete" x:Name="btnDelete" Height="20" Width="75" /> </StackPanel> </Grid> I'm a code monkey not a pixel pusher and can't figure out which combination of Stretch's, Auto's and *'s I need. Any pushers out there that can help?? Thanks, Mark

    Read the article

  • How to get checked items in a WPF ListBox?

    - by Joan Venge
    I have a WPF ListBox where I have checkboxes, but what's the way to get the list of items that are checked? The ListBox is data binded to a Dictionary<T>. Here is the XAML: <Window x:Class="WpfApplication.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"> <Grid Margin="10"> <ListBox ItemsSource="{DynamicResource Nodes}" Grid.IsSharedSizeScope="True" x:Name="MyList"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup="Key" /> <ColumnDefinition SharedSizeGroup="Name" /> <ColumnDefinition SharedSizeGroup="Id" /> </Grid.ColumnDefinitions> <CheckBox Name="NodeItem" Click="OnItemChecked"> <StackPanel Orientation="Horizontal"> <TextBlock Margin="2" Text="{Binding Value.Name}" Grid.Column="1"/> <TextBlock Margin="2" Text="-" Grid.Column="2"/> <TextBlock Margin="2" Text="{Binding Value.Id}" Grid.Column="3"/> </StackPanel> </CheckBox> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </Window>

    Read the article

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