Search Results

Search found 6871 results on 275 pages for 'wpf xaml'.

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

  • Visual Studio 2010 randomly crashes when editing XAML

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

    Read the article

  • How to use a derived ControlTemplate in WPF

    - by Frank Fella
    The following xaml code works: <Window x:Class="DerivedTemplateBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DerivedTemplateBug" Title="Window1" Height="300" Width="300"> <Button> <Button.Template> <ControlTemplate> <Border BorderBrush="Black" BorderThickness="2"> <TextBlock>Testing!</TextBlock> </Border> </ControlTemplate> </Button.Template> </Button> </Window> Now, if you define the following data template: using System.Windows.Controls; namespace DerivedTemplateBug { public class DerivedTemplate : ControlTemplate { } } And then swap the ControlTemplate for the derived class: <Window x:Class="DerivedTemplateBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DerivedTemplateBug" Title="Window1" Height="300" Width="300"> <Button> <Button.Template> <local:DerivedTemplate> <Border BorderBrush="Black" BorderThickness="2"> <TextBlock>Testing!</TextBlock> </Border> </local:DerivedTemplate> </Button.Template> </Button> </Window> You get the following error: Invalid ContentPropertyAttribute on type 'DerivedTemplateBug.DerivedTemplate', property 'Content' not found. Can anyone tell my why this is the case?

    Read the article

  • WPF Resource Dictionary in a separate assembly

    - by Gustavo Cavalcanti
    I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better if I compile these resources in one single assembly and have my applications reference it, right? After the resource assembly is built, how can I reference it in the App.xaml of my applications? Currently I use ResourceDictionary.MergedDictionaries to merge the individual dictionary files. If I have them in an assembly, how can I reference them in xaml? Thanks for your help! Gustavo

    Read the article

  • XAML trigger as StaticResource

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

    Read the article

  • WPF: How to specify units in Dialog Units?

    - by Ian Boyd
    i'm trying to figure out how to layout a simple dialog in WPF using the proper dialog units (DLUs). i spent about two hours dimensioning this sample dialog box from Windows Vista with the various dlu measurements. Can someone please give the corresponding XAML markup that generates this dialog box? (Image Link) Now admittedly i know almost nothing about WPF XAML. Every time i start, i get stymied because i cannot figure out how to place any control. It seems that everything in WPF must be contained on a panel of some kind. There's StackPanels, FlowPanels, DockPanel, Grid, etc. If you don't have one of these then it won't compile. The only XAML i've been able to come up with (uing XAMLPad) so far: <DockPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Image Width="23" /> <Label>Are you sure you want to move this file to the Recycle Bin?</Label> <Image Width="60" /> <Label>117__6.jpg</Label> <Label>Type: ACDSee JPG Image</Label> <Label>Rating: Unrated</Label> <Label>Dimensions: 1072 × 712</Label> <Button Content="Yes" Width="50" Height="14"/> <Button Content="Cancel" Width="50" Height="14"/> </DockPanel> Which renders as a gaudy monstrosity. None of the controls are placed or sized right. i cannot figure out how to position controls in a window, nor size them properly. Can someone turn that screenshot into XAML? Note: You're not allowed to measure the screenshot. All the Dialog Unit (dlu) widths and heights are specified. Note: 1 horizontal DLU != 1 vertical DLU. Horizontal and vertical DLUs are different sizes. Links Microsoft User Experience Guidelines: Recommended sizing and spacing Microsoft User Experience Guidelines: Layout Metrics Bump: 2011/05/14 (15 months later)

    Read the article

  • Translate ImageButton from C# to XAML

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

    Read the article

  • Conditional XAML

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

    Read the article

  • User defined top level control in XAML

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

    Read the article

  • "Genie" animation effect in XAML

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

    Read the article

  • Set Validation Tooltip in CodeBehind instead of XAML

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

    Read the article

  • Xaml TabControl in the top of window

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

    Read the article

  • Assembly-wide / root-level styles in WPF class library

    - by WarpedBoard
    I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/). I've created several windows, and am now attempting to create a common style set for them. However, as it's a class library (instead of a WPF app), I don't have an app.xaml (and its contained Application & corresponding Application.Resources) in which to store these styles for global access. So: How can I create a top-level set of style definitions that'll be seen by all xaml files in the assembly, given that I do not have app.xaml (see above)? And/or is it possible to add a working app.xaml to a class library? FYI, I did try creating a ResourceDictionary in a ResourceDictionary.xaml file, and include it in each window within a "Window.Resources" block. That turned out to solve the styling of Buttons, etc... but not for the enclosing Window. I can put 'Style="{StaticResource MyWindowStyle}"' in the Window's opening block, and it compiles and shows up in the VS Design window fine, but during actual runtime I get a parse exception (MyWindowStyle could not be found; I'm guessing Visual Studio sees the dictionary included after the line in question, but the CRL does things more sequentially and therefore hasn't loaded the ResourceDictionary yet).

    Read the article

  • WPF ResourceDictionary and DynamicResource

    - by lanicor
    i am new to WPF so maybe this will be "noob" question but i can't find answer to it (and it seems so easy)... well i am programing WPF app and i want to use smth similar to css for webpages, so i found ResourceDictionary and tried to use it... I have main window in which i create Frame and on click some UserControl is loaded to that same Frame.I include my ResourceDictionary (root/style/Styles.xaml) to my main window like this: <Window.Resources> <ResourceDictionary x:Key="styles" Source="style/Styles.xaml" /> </Window.Resources> in which i have: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ProductsRequired" TargetType="{x:Type Label}"> <Setter Property="Height" Value="28" /> ... I don't use it on my main window but want to use it on my UserControls, which are loaded to that main window and i try to use it like this: <Label Name="product1" Style="{DynamicResource ProductsRequired}" /> Warning i am getting all the time is: The resource "ProductsRequired" could not be resolved. I even tried including Styles to my UserControl <UserControl.Resources> <ResourceDictionary x:Key="styles" Source="../style/Styles.xaml" /> </UserControl.Resources> and nothing happens... Well my question is long but i wanted to be clear... :) P.S. all that logic works in C# code btw private ResourceDictionary myStyles = new ResourceDictionary(); Style ProductsRequired = myStyles["ProductsRequired"] as Style; product1.Style = ProductsRequired;

    Read the article

  • Problem with derived ControlTemplates in WPF

    - by Frank Fella
    The following xaml code works: <Window x:Class="DerivedTemplateBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DerivedTemplateBug" Title="Window1" Height="300" Width="300"> <Button> <Button.Template> <ControlTemplate> <Border BorderBrush="Black" BorderThickness="2"> <TextBlock>Testing!</TextBlock> </Border> </ControlTemplate> </Button.Template> </Button> </Window> Now, if you define the following data template: using System.Windows.Controls; namespace DerivedTemplateBug { public class DerivedTemplate : ControlTemplate { } } And then swap the ControlTemplate for the derived class: <Window x:Class="DerivedTemplateBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DerivedTemplateBug" Title="Window1" Height="300" Width="300"> <Button> <Button.Template> <local:DerivedTemplate> <Border BorderBrush="Black" BorderThickness="2"> <TextBlock>Testing!</TextBlock> </Border> </local:DerivedTemplate> </Button.Template> </Button> </Window> You get the following error: Invalid ContentPropertyAttribute on type 'DerivedTemplateBug.DerivedTemplate', property 'Content' not found. Can anyone tell me why this is the case?

    Read the article

  • WPF app startup problems

    - by Dave
    My brain is all over the map trying to fully understand Unity right now. So I decided to just dive in and start adding it in a branch to see where it takes me. Surprisingly enough (or maybe not), I am stuck just getting my darn Application to load properly. It seems like the right way to do this is to override OnStartup in App.cs. I've removed my StartupUri from App.xaml so it doesn't create my GUI XAML. My App.cs now looks something like this: public partial class App : Application { private IUnityContainer container { get; set; } protected override void OnStartup(StartupEventArgs e) { container = new UnityContainer(); GUI gui = new GUI(); gui.Show(); } protected override void OnExit(ExitEventArgs e) { container.Dispose(); base.OnExit(e); } } The problem is that nothing happens when I start the app! I put a breakpoint at the container assignment, and it never gets hit. What am I missing? App.xaml is currently set to ApplicationDefinition, but I'd expect this to work because some sample Unity + WPF code I'm looking at (from Codeplex) does the exact same thing, except that it works! I've also started the app by single-stepping, and it eventually hits the first line in App.xaml. When I step into this line, that's when the app just starts "running", but I don't see anything (and my breakpoint isn't hit). If I do the exact same thing in the sample application, stepping into App.xaml puts me right into OnStartup, which is what I'd expect to happen. Argh! Is it a Bad Thing to just put the Unity construction in my GUI's Window_Loaded event handler? Does it really need to be at the App level?

    Read the article

  • WPF combo box, adding an all options item, when binding to an Observable Collection

    - by Joel Barsotti
    So I've got an object that has an observable collection. Most places I bind to this collection I only want the user to select a single item. But in one place I want the combobox to include an all items option. Is the way to do this simply with xaml converter? It seems like doing it in the view model would be a good idea, but it's really a lot dependency object goop to basically wire up an collection that is two objects deep for an on change event, where as the xaml converter just works. But I always feel like xaml converters should be generic and reusable, where in this instance, the xaml converter would be more of a one off. Of course the third option would be to create one off list for UI in the object that contains the standard observable collection. But this seems to be mixing the logic and presentation in a way that makes me uncomfortable.

    Read the article

  • WPF: capturing XAML into subclassed control

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

    Read the article

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

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

    Read the article

  • Working on WPF application Memory Profiling

    - by akjoshi
    Today, I am going to start with the task of memory profiling the WPF application, on which I am working from past few months. I have successfully done this in past, fixing a lot of memory leaks and improving the performance of WPF applications; As in past, I am hopeful of fixing some very interesting bugs and improve the application performance. I am very excited as current application is very different from the previous WPF applications I had profiled, all the previous application were pure WPF...(read more)

    Read the article

  • C# WPF XAML DataTable binding to relation

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

    Read the article

  • C# WPF XAML DataTable binding to relationship

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

    Read the article

  • Binding a TreeView with ContextMenu in Xaml

    - by Michael Stoll
    I'm pretty new to Xaml and need some advise. A TreeView should be bound to a hierarchical object structure. The TreeView should have a context menu, which is specific for each object type. I've tried the following: <TreeView> <TreeView.Resources> <DataTemplate x:Key="RoomTemplate"> <TreeViewItem Header="{Binding Name}"> <TreeViewItem.ContextMenu> <ContextMenu> <MenuItem Header="Open" /> <MenuItem Header="Remove" /> </ContextMenu> </TreeViewItem.ContextMenu> </TreeViewItem> </DataTemplate> </TreeView.Resources> <TreeViewItem Header="{Binding Name}" Name="tviRoot" IsExpanded="True" > <TreeViewItem Header="Rooms" ItemsSource="{Binding Rooms}" ItemTemplate="{StaticResource RoomTemplate}"> <TreeViewItem.ContextMenu> <ContextMenu> <MenuItem Header="Add room"></MenuItem> </ContextMenu> </TreeViewItem.ContextMenu> </TreeViewItem> </TreeViewItem> But with this markup the behavior is as intended, but the child items (the rooms) are indented too much. Anyway all the bining samples I could find use TextBlock instead of TreeViewItem in the DataTemplate, but wonder how to integrate the ContextMenu there.

    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

  • help with grouping and sorting for TreeView in xaml

    - by danhotb
    I am having problems getting my head around grouping and sorting in xaml and hope someone can get me straightened out! I have creaed an xml file from a tree of files and folders (just like windows explorer) that can be serveral levels deep. I have bound a TreeView control to an xml datasource and it works great! It sorts everything alphabetically but ... I would like it to sort all folders first then all files, rather than folders listed with files, as it does now. the xml : if you load this to a treeviw it will display the two files before the folder because they are first in alpha-order. here is my code: <!-- This will contain the XML-data. --> <XmlDataProvider x:Key="xmlDP" XPath="*"> <x:XData> <Select_Project /> </x:XData> </XmlDataProvider> <!-- This HierarchicalDataTemplate will visualize all XML-nodes --> <HierarchicalDataTemplate DataType="project" ItemsSource ="{Binding}"> <TextBlock Text="{Binding XPath=@name}" /> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="folder" ItemsSource ="{Binding}"> <TextBlock Text="{Binding XPath=@name}" /> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="file" ItemsSource ="{Binding}"> <TextBlock Text="{Binding XPath=@name}" /> </HierarchicalDataTemplate> <CollectionViewSource x:Key="projectView" Source="{StaticResource xmlDP}"> <CollectionViewSource.SortDescriptions> <!-- ADD SORT DESCRIPTION HERE --> </CollectionViewSource.SortDescriptions> </CollectionViewSource> <TreeView Margin="11,79.992,18,19.089" Name="tvProject" BorderThickness="1" FontSize="12" FontFamily="Verdana"> <TreeViewItem ItemsSource="{Binding Source={StaticResource xmlDP}, XPath=*}" Header="Project"/> </TreeView>

    Read the article

  • C# WPF XAML Problem with icon in GridViewColumn

    - by Alex
    I've created a ListView with a GridView component in it. Now trying to fill one of the cells with an icon (PNG) like in the code sample below (save_icon.png): <ListView.View> <GridView> <GridViewColumn Header="Date" Width="Auto" DisplayMemberBinding="{Binding Date}" /> <GridViewColumn Header="Time" Width="Auto" DisplayMemberBinding="{Binding Time}" /> <GridViewColumn Header="FriendlyName" Width="Auto" DisplayMemberBinding="{Binding FriendlyName}" /> <GridViewColumn Width="Auto"> <Image Source="save_icon.png" /> </GridViewColumn> </GridView> </ListView.View> Visual Studio gives me an error on the line, where i put the icon into the column (ERROR: "Error 35: The file save_icon.png is not part of the project or its 'Build Action' property is not set to 'Resource'.") I added the icon to the project as a resource and when i start the app, everything works (the icon appears at the right place). But the WPF designer window can't be reloaded and i'm not able to see changes in the designer, when i change the XAML code. Can somebody explain this error or am i doing something wrong? Thanks for every hint in advance!

    Read the article

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