Search Results

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

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

  • Generate BitmapSource from UIElement

    - by Joel
    I am attempting to generate a BitmapFrame that is based on a UIElement. Here is my function: private BitmapFrame RenderToBitmap2() { RenderTargetBitmap renderBitmap = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); VisualBrush aVisualBrush = new VisualBrush(GenerateTestStackPanel()); drawingContext.DrawRectangle(aVisualBrush, new Pen(Brushes.Green, 2), new Rect(new Size(150, 150))); drawingContext.Close(); renderBitmap.Render(drawingVisual); return BitmapFrame.Create(renderBitmap); } For testing and debugging purposes, I am using an additional function that creates a simple StackFrame that should create a valid visual element that can be represented: private StackPanel GenerateTestStackPanel() { // Create a red Ellipse. Ellipse myEllipse = new Ellipse(); myEllipse.Fill = Brushes.Green; myEllipse.StrokeThickness = 2; myEllipse.Stroke = Brushes.Black; // Set the width and height of the Ellipse. myEllipse.Width = 200; myEllipse.Height = 200; // Add the Ellipse to the StackPanel. StackPanel myStackPanel = new StackPanel(); myStackPanel.Children.Add(myEllipse); return myStackPanel; } For some reason, the VisualBrush is not being rendered in the DrawRetangle(...) function. I can see the green border but nothing else. In addition, if I swap out the VisualBrush with a standard brush, it works great: drawingContext.DrawRectangle(Brushes.Plum, new Pen(Brushes.Green, 2), new Rect(new Size(150, 150))); Thanks in advance! -Joel

    Read the article

  • saving WPF InkCanvas to a JPG - image is getting cropped

    - by Jason
    I have a WPF InkCanvas control I'm using to capture a signature in my application. The control looks like this - it's 700x300 However, when I save it as a JPG, the resulting image looks like this, also 700x300 The code I'm using to save sigPath = System.IO.Path.GetTempFileName(); MemoryStream ms = new MemoryStream(); FileStream fs = new FileStream(sigPath, FileMode.Create); RenderTargetBitmap rtb = new RenderTargetBitmap((int)inkSig.Width, (int)inkSig.Height, 96d, 96d, PixelFormats.Default); rtb.Render(inkSig); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); encoder.Save(fs); fs.Close(); This is the XAML I'm using: <Window x:Class="Consent.Client.SigPanel" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Transparent" Topmost="True" AllowsTransparency="True" Title="SigPanel" Left="0" Top="0" Height="1024" Width="768" WindowStyle ="None" ShowInTaskbar="False" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" > <Border BorderThickness="1" BorderBrush="Black" Background='#FFFFFFFF' x:Name='DocumentRoot' Width='750' Height='400' CornerRadius='10'> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock Name="txtLabel" FontSize="24" HorizontalAlignment="Center" >Label</TextBlock> <InkCanvas Opacity="1" Background="Beige" Name="inkSig" Width="700" Height="300" /> <StackPanel HorizontalAlignment="Center" Orientation="Horizontal"> <Button FontSize="24" Margin="10" Width="150" Name="btnSave" Click="btnSave_Click">Save</Button> <Button FontSize="24" Margin="10" Width="150" Name="btnCancel" Click="btnCancel_Click">Cancel</Button> <Button FontSize="24" Margin="10" Width="150" Name="btnClear" Click="btnClear_Click">Clear</Button> </StackPanel> </StackPanel> </Border> In the past this worked perfectly. I can't figure out what changed that is causing the image to shift when it is saved.

    Read the article

  • How do I get my custom WPF textbox to fill correctly?

    - by Dan Ryan
    I am trying to create a custom WPF textbox control that extends the standard textbox control but the extended textbox behaves differently when placed in control containers. Within my Window I have a stackpanel with a standard textbox and my extended textbox: <StackPanel Margin="10"> <TextBox Height="21" /> <l:SearchTextBox Search="SearchTextBox_Search" Height="21" Margin="0, 10, 0, 0" SearchMode="Delayed" HorizontalAlignment="Left" /> </StackPanel> The standard textbox stretches the length of the StackPanel whereas the custom textbox does not. How can I get the controls to behave the same? The styling for the custom textbox is shown below: <Style x:Key="{x:Type UIControls:SearchTextBox}" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type UIControls:SearchTextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type UIControls:SearchTextBox}"> <TextBox /> </ControlTemplate> </Setter.Value> </Setter> </Style>

    Read the article

  • Animate UserControl in WPF?

    - by sanjeev40084
    I have two xaml file one is MainWindow.xaml and other is userControl EditTaskView.xaml. In MainWindow.xaml it consists of listbox and when double clicked any item of listbox, it displays other window (edit window) from EditView userControl. I am trying to animate this userControl everytime whenever any item from the listbox is double clicked. I added some animation in userControl however the animation only gets run once. How can i make my animation run everytime whenever any item from the listbox is clicked? <ListBox x:Name="lstBxTask" Style="{StaticResource ListBoxItems}" MouseDoubleClick="lstBxTask_MouseDoubleClick"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <Rectangle Style="{StaticResource LineBetweenListBox}"/> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Taskname}" Style="{StaticResource TextInListBox}"/> <Button Name="btnDelete" Style="{StaticResource DeleteButton}" Click="btnDelete_Click"/> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <ToDoTask:EditTaskView x:Name="EditTask" Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="2" Visibility="Collapsed"/> In the MainWindow code, there is mouse double click event, which changes the visibility of EditTaskView to Visible. Suggestions?

    Read the article

  • WPF - expander Collapsed event being triggered by child controls with validation

    - by Shaboboo
    I have an expander that contains an ItemsControl. The items in the itemsControl are templated, some have textboxes in them, others have checkboxes. Both have bindings that cause validation. The styling and validation is working as expected. The problem is when I first expand the expander and cause a change to either control, the expander collapses again, this is not what I want. If I repeat this a second time this does not happen. I'm not sure what is triggering this strange behaviour. I've tried setting the focus to the itemsControl when the expander expands with no luck. What is differnt the second time it's expanded? Could it be the validation? Any Ideas? XAML: <Expander Header="{Binding SubSectionName}" Padding="0" > <ItemsControl ItemsSource="{Binding ConfigSubSectionSettings}" ItemTemplateSelector="{StaticResource Settings_Selector}" /> </Expander> <!-- Templates selected by the ItemTemplateSelector --> <DataTemplate x:Key="subSection_Bool"> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="lbl" Text="{Binding SubSectionName}" > <CheckBox x:Name="chk" IsChecked="{Binding BoolValue, ValidatesOnDataErrors=True}" VerticalAlignment="Center" Margin="2" > </StackPanel > </DataTemplate> <DataTemplate x:Key="subSection_Text"> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="lbl" Text="{Binding SubSectionName}" /> <TextBox x:Name="txt" VerticalAlignment="Center" Text="{Binding StringValue, ValidatesOnDataErrors=True}" /> </StackPanel> </DataTemplate>

    Read the article

  • Insufferable word wrap in Visual Studio XAML editor - is there any relief for 2010?

    - by DanM
    Just curious if the XAML editor is any better at auto-formatting and wrapping attributes in Visual Studio 2010. Here's how the editor auto wraps attributes in VS 2008: <StackPanel Grid.Row="0" Grid.ColumnSpan="3"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" FontWeight="Bold" Text="Current User:" /> <ComboBox x:Name="_usersComboBox" Margin="5,0,0,0" Width="200" ItemsSource="{Binding Users}" SelectedValuePath="Name" SelectedValue="System Administration"> <ComboBox.ItemTemplate> <DataTemplate> Here's how I'd like the editor to auto wrap attributes: <StackPanel Grid.Row="0" Grid.ColumnSpan="3"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" FontWeight="Bold" Text="Current User:" /> <ComboBox x:Name="_usersComboBox" Margin="5,0,0,0" Width="200" ItemsSource="{Binding Users}" SelectedValuePath="Name" SelectedValue="System Administration"> <ComboBox.ItemTemplate> <DataTemplate> Does VS 2010 grant my wish?

    Read the article

  • Is it possible to template a template in WPF XAML?

    - by imekon
    Is it possible to use templates within templates? For instance, I have the following two templates: <HierarchicalDataTemplate x:Key="RecursiveTemplate" ItemsSource="{Binding Children}"> <StackPanel Margin="1" Orientation="Horizontal"> <Ellipse Fill="DarkGreen" Width="14" Height="14"/> <TextBlock MouseDown="OnTreeMouseDown" TargetUpdated="OnTargetUpdated" Visibility="{Binding Editing, Converter={StaticResource visibilityInverter}}" Margin="5" Text="{Binding Name}"/> <TextBox PreviewKeyDown="OnTreeKeyDown" Visibility="{Binding Editing, Converter={StaticResource visibilityConverter}}" Margin="2" Text="{Binding Name}"/> </StackPanel> </HierarchicalDataTemplate> <HierarchicalDataTemplate x:Key="ContainerTemplate" ItemsSource="{Binding Children}"> <StackPanel Margin="1" Orientation="Horizontal"> <Ellipse Fill="DarkBlue" Width="14" Height="14"/> <TextBlock MouseDown="OnTreeMouseDown" TargetUpdated="OnTargetUpdated" Visibility="{Binding Editing, Converter={StaticResource visibilityInverter}}" Margin="5" Text="{Binding Name}"/> <TextBox PreviewKeyDown="OnTreeKeyDown" Visibility="{Binding Editing, Converter={StaticResource visibilityConverter}}" Margin="2" Text="{Binding Name}"/> </StackPanel> </HierarchicalDataTemplate> There's a section of identical XAML: <TextBlock MouseDown="OnTreeMouseDown" TargetUpdated="OnTargetUpdated" Visibility="{Binding Editing, Converter={StaticResource visibilityInverter}}" Margin="5" Text="{Binding Name}"/> <TextBox PreviewKeyDown="OnTreeKeyDown" Visibility="{Binding Editing, Converter={StaticResource visibilityConverter}}" Margin="2" Text="{Binding Name}"/> Is it possible to move that to a resource and refer to it by name, rather than repeat it?

    Read the article

  • Silverlight - Get the ItemsControl of a DataTemplate

    - by user208662
    Hello, I have a Silverlight application that is using a DataGrid. Inside of that DataGrid I have a DataTemplate that is defined like the following: <Grid x:Name="myGrid" Tag="{Binding}" Loaded="myGrid_Loaded"> <ItemsControl ItemsSource="{Binding MyItems}" Tag="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Width="138"> <TextBlock Text="{Binding Type}" /> <TextBox x:Name="myTextBox" TextChanged="myTextBox_TextChanged" /> </StackPanel> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> When a user enters text into the TextBox, I have an event (myTextBox_TextChanged) that must be fired at this point. When that event gets fired, I would like to get the ItemsControl element that is the container for this TextBox. How do I get that ItemsControl from my event handler? Please note: Because the ItemsControl is in the DataTemplate of DataGrid, I don't believe I can just add an x:Name and reference it from my code-behind. Or is there a way to do that? Thank you!

    Read the article

  • Dependency Property ListBox

    - by developer
    Hi All, I want to use a dependency property, so that my label displays values selected in the listbox. This is just to more clearly understand the working of a dependency property. <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:WPFToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" xmlns:local="clr-namespace:WpfApplication1" x:Name="MyWindow" Height="200" Width="300" > <StackPanel> <ListBox x:Name="lbColor" Width="248" Height="56" ItemsSource="{Binding TestColor}"/> <StackPanel> <Label Content="{Binding Path=Test, ElementName=lbColor}" /> </StackPanel> </StackPanel> </Window> Code Behind, namespace WpfApplication1 { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public ObservableCollection<string> TestColor { get; set; } public String Test { get { return (String)GetValue(TestProperty); } set { SetValue(TestProperty, value); } } // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc... public static readonly DependencyProperty TestProperty = DependencyProperty.Register("Test", typeof(String), typeof(ListBox), new UIPropertyMetadata("Test1")); public Window1() { InitializeComponent(); TestColor = new ObservableCollection<string>(); DataContext = this; TestColor.Add("Red"); TestColor.Add("Orange"); TestColor.Add("Yellow"); TestColor.Add("Green"); TestColor.Add("Blue"); } } } Can anyone explain me how will I accompalish this using a dependency property. Somehow I am very confused with the Dependency Property concept, and I just wanted to see a working example for that.

    Read the article

  • silverlight treeview not loading subitems

    - by Jakob
    I'm interested in finding out why this isn't working: I have a treeview with some hierarchicaldatatemplates looking like this: <UserControl.Resources> <sdk:HierarchicalDataTemplate x:Key="nodeEntry"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Title}" /> </StackPanel> </sdk:HierarchicalDataTemplate> <sdk:HierarchicalDataTemplate x:Key="rootEntry" ItemsSource="{Binding Path=Nodes}" ItemTemplate="{StaticResource nodeEntry}"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Name}" /> </StackPanel> </sdk:HierarchicalDataTemplate> </UserControl.Resources> <sdk:TreeView Height="250" HorizontalAlignment="Left" ItemTemplate="{StaticResource rootEntry}" ItemsSource="{Binding ElementName=subjectDomainDataSource, Path=Data}" Name="rootTreeView" VerticalAlignment="Top" Width="180"/> The data is passed to the treeview from a domainservice using this method: public IEnumerable<Subject> GetSubjectList(Guid userid) { DataLoadOptions loadopts = new DataLoadOptions(); loadopts.LoadWith<Root>(s => s.Nodes); this.DataContext.LoadOptions = loadopts; return this.DataContext.Roots; } why then are only the root nodes shown in the treeview as if it only loaded a flat list, and not a hierarchy where the root Loads the NodesCollection?

    Read the article

  • Setting WPF control background image using styles?

    - by aviv
    Hi, I have a set of buttons inside a stack panel. I want them all to have a background image. How can i do it using styles? since i don't want to set manually the Background image for each button. Here is a code snippet: <StackPanel Orientation="Horizontal" Height="100px" VerticalAlignment="Top"> <StackPanel.Resources> <Style TargetType="Button"> <Setter Property="Margin" Value="2,4" /> </Style> </StackPanel.Resources> <Button Width="127px" Height="79px" VerticalAlignment="Bottom"> <Button.Background> <ImageBrush ImageSource="images/Tab.png" /> </Button.Background> </Button> <Button>A</Button> <Button>R</Button> <Button>S</Button> </StackPanel> Thanks.

    Read the article

  • WPF: Horizontal Alignment

    - by emptyset
    Probably I'm just missing something obvious, but I can't get the image in my DataTemplate to align to the right in the Grid, so that when the window is stretched, the image is "pulled" to the right as well: <Window.Resources> <DataTemplate x:Key="PersonTemplate" DataType="Minimal.Client.Person"> <Border BorderBrush="Purple" BorderThickness="2" CornerRadius="2" Padding="5" Margin="5"> <Grid Margin="10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" MinWidth="200"/> <ColumnDefinition Width="Auto" MaxWidth="200"/> </Grid.ColumnDefinitions> <StackPanel Grid.Column ="0" Orientation="Horizontal" > <TextBlock FontFamily="Verdana" FontSize="16" FontWeight="Bold" Text="{Binding LastName}" /> <TextBlock FontFamily="Verdana" FontSize="16" Text=", " /> <TextBlock FontFamily="Verdana" FontSize="16" Text="{Binding FirstName}" /> </StackPanel> <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Right"> <Border BorderBrush="Black" BorderThickness="1"> <Image Source="{Binding Picture}" Width="180" Height="150" /> </Border> </StackPanel> </Grid> </Border> </DataTemplate> </Window.Resources> Any suggestions?

    Read the article

  • WPF Buttons Style

    - by Polaris
    I have WPF Form which has many buttons with the same code. Appearance of all buttons must be the same For example, code for one of these buttons <Button x:Name="btnAddRelative" Width="120" Click="btnAddRelative_Click" > <Button.Content> <StackPanel Orientation="Horizontal"> <Image Height="26" HorizontalAlignment="Left"> <Image.Source> <BitmapImage UriSource="images/add.png" /> </Image.Source> </Image> <TextBlock Text=" Add Relative" Height="20" VerticalAlignment="Center"/> </StackPanel> </Button.Content> </Button> How can I create one style and use it for all my buttons. All buttons has the same png image, only their text different. How can I do this. I tried to do this with Style object in Resource Section: <UserControl.Resources> <Style TargetType="Button" x:Key="AddStyle"> <Setter Property="Content"> <Setter.Value> <StackPanel Orientation="Horizontal"> <Image Height="26" HorizontalAlignment="Left"> <Image.Source> <BitmapImage UriSource="images/add.png" /> </Image.Source> </Image> <TextBlock Text=" " Height="20" VerticalAlignment="Center"/> </StackPanel> </Setter.Value> </Setter> </Style> </UserControl.Resources> But this code not work. Can any body know how can I do this?

    Read the article

  • MVVM Listbox DataTemplate SelectedItem

    - by StinkerPeter
    I am using a ListBox with a DataTemplate as shown below (xaml simplified and variable names changed). <ListBox ItemsSource="{Binding Path=ObservCollectionItems}" SelectedItem="{Binding Path=SelectedItemVar, Mode=TwoWay}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding SomeVar}" /> <Border> <StackPanel> <Button Content="String1" Command="{Binding DataContext.Command1} RelativeSource={RelativeSource FindAncestor, ListBox, 1}}" /> <Button Content="String2" Command="{Binding DataContext.Command2} RelativeSource={RelativeSource FindAncestor, ListBox, 1}}" /> </StackPanel> </Border> </StackPanel> </DataTemplate> <ListBox.ItemTemplate> </ListBox> I need the SelectedItemVar (dependency property) to update when I click on one of the buttons. SelectedItemVar is then used for the respective button's command. SelectedItemVar does update when I click on the TextBlock or the Border, but not when I click either button. I found a non-MVVM solution to this problem here. I do not want to add code in the file-behind to solve this, as they did in the link. Is there a clean solution that can be done in XAML. Beyond the non-MVVM solutions, I have not found anyone with this problem. I would have thought this was fairly common. Finally, I found this Command="{Binding DataContext.CommandName} RelativeSource={RelativeSource FindAncestor, ListBox, 1} for the Command binding. I do not fully understand what it is doing, but I do know that the command wasn't firing when I was binding directly to CommandName.

    Read the article

  • Custom button with property as StaticResource

    - by alin
    I am trying to achieve the following thing: use an svg image into a custom button. In order to do this I created a Custom button: public class MainButton : Button { static MainButton() { DefaultStyleKeyProperty.OverrideMetadata(typeof(MainButton), new FrameworkPropertyMetadata(typeof(MainButton))); } public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MainButton), new UIPropertyMetadata("")); public object Image { get { return (object)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } } public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(object), typeof(MainButton), new UIPropertyMetadata("")); } I took a svg file, opened it in inkscape and saved it as xaml file. I opened Themes.xaml and added the created xaml image as a ControlTemplate And the button style is: Style TargetType="{x:Type local:MainButton}" <StackPanel Canvas.Top="12" Canvas.Left="0" Canvas.ZIndex="2" Width="80"> <ContentControl x:Name="Img" Template="{StaticResource Home}" /> </StackPanel> <StackPanel x:Name="spText" Canvas.Top="45" Canvas.Left="1" Canvas.ZIndex="1" Width="80"> <TextBlock x:Name="Txt" Text="{Binding Path=(local:MainButton.Text), RelativeSource ={RelativeSource FindAncestor, AncestorType ={x:Type Button}}}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="14"/> </StackPanel> ... As you can see I have hardcoded the StaticResource name I want to be able to have a binding with property Image on this Template, something like So that I can set the Image property of the button with the name of the StaticResource I want. For example, having beside "Home" image, another one "Back" I would have two buttons in MainWindow declared like this: Any advice is kindly taken. Thank you for your time.

    Read the article

  • Populate two column grid with databinding?

    - by Richard
    How do i populate a two column grid with objects from my observable collection? I've tried to achieve this effect by using the tookits wrap panel but the items just stack. <toolkit:WrapPanel Margin="5,0,0,0" Width="400"> <ItemsControl ItemsSource="{Binding Trips}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Height="236" Width="182"> <Button Style="{StaticResource VasttrafikButtonTrip}"> <StackPanel Width="152" Height="140"> <TextBlock Text="{Binding FromName}" /> <TextBlock FontFamily="Segoe WP Semibold" Text="till" /> <TextBlock Text="{Binding ToName}" /> </StackPanel> </Button> <TextBlock HorizontalAlignment="Left" Width="160" FontSize="16" FontWeight="ExtraBlack" Text="{Binding TravelTimeText}" /> <TextBlock HorizontalAlignment="Left" Width="160" Margin="0,-6,0,0" FontSize="16" Text="{Binding TransferCountText}" /> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </toolkit:WrapPanel>

    Read the article

  • Binding ComboBox Item with a text property of different DataContext

    - by Jhelumi786
    Hi Everyone, I have a comboBox as below. What I want is to bind the selectedItem value to a Text property of a datacontext so that another DataTemplate can show the Image. Please note that the Combobox and Target Image elements are on two different DataTemplates so that's why I need to update the Text Property (ImageName) ofDataContext at backend. <ComboBox x:Name="cboOverlay" Grid.Row="0" Grid.Column="1" SelectedIndex="0" > <ComboBoxItem Name="BC_OL" IsSelected="True"> <StackPanel Orientation="Horizontal"> <Image Source="Images\BC_OL.jpg" Width="100" Height="25" Canvas.Top="0" Canvas.Left="0" /> <TextBlock Width="100" VerticalAlignment="Center" TextAlignment="Center"><Bold>Image1</Bold></TextBlock> </StackPanel> </ComboBoxItem> <ComboBoxItem Name="Indian_OL"> <StackPanel Orientation="Horizontal"> <Image Source="Images\Indian_OL.jpg" Width="100" Height="25" Canvas.Top="0" Canvas.Left="0" /> <TextBlock Width="100" VerticalAlignment="Center" TextAlignment="Center"><Bold>Image2</Bold></TextBlock> </StackPanel> </ComboBoxItem> </ComboBox> <Image Source="{Binding Path=Image}" Width="81" Height="25" Canvas.Top="0" Canvas.Left="0" />

    Read the article

  • WPF problem modify style of images in multiple Button Templates

    - by user556415
    I'm trying to create a control panel for a video camera, the panel has buttons for up, down, left and right etc. Each camera function up, down, left and right is represented by three images (see code below) for the left side, middle and right side. The control panel is circular so the corner images kind of overlap (its complicated to explain this without a visual). When I click on up for example I have to hide the initial three images (leftside, middle and right side) and display another three images for left , middle and right that indicate that the button is pressed. I am achieving this by having a grid inside a button template. The problem I have is that for the corner images for the control there are really four images that represent this. For example for the top left corner the four images would be represent 1. Top not clicked. 2. Top Clicked and 3. Left Not clicked and 4. Left Clicked. My problem is if I need to make the images contained within the Top button have precedence when the top control is clicked or the images in the left button have precedence when the left button is clicked. So it's like I want to modify the left button's image visible property when the top button is clicked and vise versa. This is really difficult to explain so I apologize if it makes little sense but I can email the source code on request if anyone is interested in my predicament. <Grid> <Canvas> <!--<StackPanel>--> <Button Name="TopSide" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height="34" Width="102" Canvas.Left="97" Canvas.Top="60" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid Width="100"> <Canvas> <Image Name="TopRightNormal" Source="Resources/topright_off.jpg" Height="34" Width="34" Canvas.Left="66"></Image> <Image Name="TopRightDown" Source="Resources/topright_down.jpg" Height="34" Width="34" Canvas.Left="66" Visibility="Hidden" ></Image> <Image Name="TopNormal" Source="Resources/topcenter_off.jpg" Height="34" Width="34" Canvas.Left="34" /> <Image Name="TopPressed" Source="Resources/topcenter_down.jpg" Height="34" Width="34" Canvas.Left="34" Visibility="Hidden" /> <Image Name="TopDisabled" Source="Resources/topcenter_off.jpg" Height="34" Width="34" Canvas.Left="34" Visibility="Hidden" /> <Image Name="TopLeftNormal" Source="Resources/topleft_off.jpg" Height="34" Width="34" Canvas.Left="2" ></Image> <Image Name="TopLeftDown" Opacity="0" Source="Resources/topleft_down.jpg" Height="34" Width="34" Canvas.Left="2" Visibility="Hidden" ></Image> </Canvas> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="TopNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopPressed" Property="Visibility" Value="Visible" /> <Setter TargetName="TopRightNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopRightDown" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopLeftDown" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftDown" Property="Opacity" Value="100" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="TopNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopDisabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <!--<StackPanel>--> <Button Name="LeftSide" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Canvas.Left="100" Canvas.Top="60" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MouseDown="Button_MouseDown_1"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid Width="34" Height="100"> <Canvas> <Image Name="TopLeftNormal" Source="Resources/topleft_off.jpg" Height="34" Width="34" Canvas.Left="0"></Image> <Image Name="TopLeftDown" Opacity="0" Source="Resources/topleft_leftdown.jpg" Height="34" Width="34" Canvas.Left="0" Visibility="Hidden" ></Image> <Image Name="Normal" Source="Resources/leftcenter_off.jpg" Height="34" Width="34" Canvas.Top="32" Canvas.Left="0"/> <Image Name="Pressed" Source="Resources/leftcenter_down.jpg" Visibility="Hidden" Canvas.Top="32" Height="34" Width="34" /> <Image Name="Disabled" Source="Resources/leftcenter_off.jpg" Visibility="Hidden" Height="34" Width="34" Canvas.Top="32" /> </Canvas> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Pressed" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="TopLeftNormal" Property="Opacity" Value="0" /> <Setter TargetName="TopLeftDown" Property="Visibility" Value="Visible" /> <Setter TargetName="TopLeftDown" Property="Opacity" Value="100" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Disabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <!--<StackPanel>--> <Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height="34" Width="34" Canvas.Left="165" Canvas.Top="92" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MouseDown="Button_MouseDown_2" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Image Name="Normal" Source="Resources/rightcenter_off.jpg" /> <Image Name="Pressed" Source="Resources/rightcenter_down.jpg" Visibility="Hidden" /> <Image Name="Disabled" Source="Resources/rightcenter_off.jpg" Visibility="Hidden" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Pressed" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden" /> <Setter TargetName="Disabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <!--<StackPanel>--> <Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height="34" Width="34" Canvas.Left="133" Canvas.Top="124" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Image Name="BottomNormal" Source="Resources/bottomcenter_off.jpg" /> <Image Name="BottomPressed" Source="Resources/bottomcenter_down.jpg" Visibility="Hidden" /> <Image Name="BottomDisabled" Source="Resources/bottomcenter_off.jpg" Visibility="Hidden" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="BottomNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="BottomPressed" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="BottomNormal" Property="Visibility" Value="Hidden" /> <Setter TargetName="BottomDisabled" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <!--</StackPanel>--> <Image Source="Resources/bottomright_off.jpg" Height="34" Width="34" Canvas.Left="165" Canvas.Top="124"></Image> <Image Source="Resources/bottomleft_off.jpg" Height="34" Width="34" Canvas.Left="100" Canvas.Top="124"></Image> <!--<ToggleButton Style="{StaticResource MyToggleButtonStyle}" Height="34" Width="34" Margin="150,100"/>--> </Canvas> </Grid>

    Read the article

  • Silverlight ~ MVVM ~ Dynamic setting of Style property based on model value

    - by eponymous23
    I have a class called Question that represents a question and it's answer. I have an application that renders an ObservableCollection of Question objects. Each Question is rendered as a StackPanel that contains a TextBlock for the question verbiage, and a TextBox for the user to enter in an answer. The questions are rendered using an ItemsControl, and I have initially set the Style of the Questions's StackPanel using a StaticResource key called 'IncorrectQuestion' (defined in UserControl.Resources section of the page). In the UserControl.Resources section, I've also defined a key calld 'CorrectQuestion' which I need to somehow apply to the Question's StackPanel when the user correctly answers the question. My problem is I'm not sure how to dynamically change the Style of the StackPanel, specifically within the constraints of a ViewModel class (i.e. I don't want to put any style selection code in the View's code-behind). My Question class has an IsCorrect property which is accurately being set when the correction is answered. I'd like to somehow reflect the IsCorrect value in the form of a Style selection. How do I do that?

    Read the article

  • Navigate to browser from selected listbox binded hyperlink (windows phone7)

    - by Ryan Smith
    I am bindind rss items from the net to this page, I cannot Seem to navigate to the link of a selected items hyper link which through binding is string. can anyone help me to navigate to weblink from a listbox item when selected ??? <ListBox Height="712" HorizontalAlignment="Left" Name="listNews" VerticalAlignment="Top" Width="468" SelectionChanged="listNews_SelectionChanged" Margin="0,-22,0,0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="132"> <Image Source="{Binding Avatar}" Height="73" Width="73" VerticalAlignment="Top" Margin="0,7,5,0"/> <StackPanel Width="370"> <TextBlock Text="{Binding Newstitle}" TextWrapping="Wrap" Foreground="#FFC8AB14" FontSize="28" /> <HyperlinkButton Name="{Binding NewsLink}" Content="{Binding NewsLink}" NavigateUri="{Binding NewsLink}" FontSize="18" ClickMode="Press" Click="Selected" /> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> private void listNews_SelectionChanged(object sender, SelectionChangedEventArgs e) { WebBrowserTask webBrowserTask = new WebBrowserTask(); webBrowserTask.URL = **???????;** webBrowserTask.Show();

    Read the article

  • Dynamic XAP loading in Task-It - Part 1

    Download Source Code NOTE 1: The source code provided is running against the RC versions of Silverlight 4 and VisualStudio 2010, so you will need to update to those bits to run it. NOTE 2: After downloading the source, be sure to set the .Web project as the StartUp Project, and Default.aspx as the Start Page In my MEF into post, MEF to the rescue in Task-It, I outlined a couple of issues I was facing and explained why I chose MEF (the Managed Extensibility Framework) to solve these issues. Other posts to check out There are a few other resources out there around dynamic XAP loading that you may want to review (by the way, Glenn Block is the main dude when it comes to MEF): Glenn Blocks 3-part series on a dynamically loaded dashboard Glenn and John Papas Silverlight TV video on dynamic xap loading These provide some great info, but didnt exactly cover the scenario I wanted to achieve in Task-Itand that is dynamically loading each of the apps pages the first time the user enters a page. The code In the code I provided for download above, I created a simple solution that shows the technique I used for dynamic XAP loading in Task-It, but without all of the other code that surrounds it. Taking all that other stuff away should make it easier to grasp. Having said that, there is still a fair amount of code involved. I am always looking for ways to make things simpler, and to achieve the desired result with as little code as possible, so if I find a better/simpler way I will blog about it, but for now this technique works for me. When I created this solution I started by creating a new Silverlight Navigation Application called DynamicXAP Loading. I then added the following line to my UriMappings in MainPage.xaml: <uriMapper:UriMapping Uri="/{assemblyName};component/{path}" MappedUri="/{assemblyName};component/{path}"/> In the section of MainPage.xaml that produces the page links in the upper right, I kept the Home link, but added a couple of new ones (page1 and page 2). These are the pages that will be dynamically (lazy) loaded: <StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">      <HyperlinkButton Style="{StaticResource LinkStyle}" NavigateUri="/Home" TargetName="ContentFrame" Content="home"/>      <Rectangle Style="{StaticResource DividerStyle}"/>      <HyperlinkButton Style="{StaticResource LinkStyle}" Content="page 1" Command="{Binding NavigateCommand}" CommandParameter="{Binding ModulePage1}"/>      <Rectangle Style="{StaticResource DividerStyle}"/>      <HyperlinkButton Style="{StaticResource LinkStyle}" Content="page 2" Command="{Binding NavigateCommand}" CommandParameter="{Binding ModulePage2}"/>  </StackPanel> In App.xaml.cs I added a bit of MEF code. In Application_Startup I call a method called InitializeContainer, which creates a PackageCatalog (a MEF thing), then I create a CompositionContainer and pass it to the CompositionHost.Initialize method. This is boiler-plate MEF stuff that allows you to do 'composition' and import 'packages'. You're welcome to do a bit more MEF research on what is happening here if you'd like, but for the purpose of this example you can just trust that it works. :-) private void Application_Startup(object sender, StartupEventArgs e) {     InitializeContainer();     this.RootVisual = new MainPage(); }   private static void InitializeContainer() {     var catalog = new PackageCatalog();     catalog.AddPackage(Package.Current);     var container = new CompositionContainer(catalog);     container.ComposeExportedValue(catalog);     CompositionHost.Initialize(container); } Infrastructure In the sample code you'll notice that there is a project in the solution called DynamicXAPLoading.Infrastructure. This is simply a Silverlight Class Library project that I created just to move stuff I considered application 'infrastructure' code into a separate place, rather than cluttering the main Silverlight project (DynamicXapLoading). I did this same thing in Task-It, as the amount of this type of code was starting to clutter up the Silverlight project, and it just seemed to make sense to move things like Enums, Constants and the like off to a separate place. In the DynamicXapLoading.Infrastructure project you'll see 3 classes: Enums - There is only one enum in here called ModuleEnum. We'll use these later. PageMetadata - We will use this class later to add metadata to a new dynamically loaded project. ViewModelBase - This is simply a base class for view models that we will use in this, as well as future samples. As mentioned in my MVVM post, I will be using the MVVM pattern throughout my code for reasons detailed in the post. By the way, the ViewModelExtension class in there allows me to do strongly-typed property changed notification, so rather than OnPropertyChanged("MyProperty"), I can do this.OnPropertyChanged(p => p.MyProperty). It's just a less error-prown approach, because if you don't spell "MyProperty" correctly using the first method, nothing will break, it just won't work. Adding a new page We currently have a couple of pages that are being dynamically (lazy) loaded, but now let's add a third page. 1. First, create a new Silverlight Application project: In this example I call it Page3. In the future you may prefer to use a different name, like DynamicXAPLoading.Page3, or even DynamicXAPLoading.Modules.Page3. It can be whatever you want. In my Task-It application I used the latter approach (with 'Modules' in the name). I do think of these application as 'modules', but Prism uses the same term, so some folks may not like that. Use whichever naming convention you feel is appropriate, but for now Page3 will do. When you change the name to Page3 and click OK, you will be presented with the Add New Project dialog: It is important that you leave the 'Host the Silverlight application in a new or existing Web site in the solution' checked, and the .Web project will be selected in the dropdown below. This will create the .xap file for this project under ClientBin in the .Web project, which is where we want it. 2. Uncheck the 'Add a test page that references the application' checkbox, and leave everything else as is. 3. Once the project is created, you can delete App.xaml and MainPage.xaml. 4. You will need to add references your new project to the following: DynamicXAPLoading.Infrastructure.dll (this is a Project reference) DynamicNavigation.dll (this is in the Libs directory under the DynamicXAPLoading project) System.ComponentModel.Composition.dll System.ComponentModel.Composition.Initialization.dll System.Windows.Controls.Navigation.dll If you have installed the latest RC bits you will find the last 3 dll's under the .NET tab in the Add Referenced dialog. They live in the following location, or if you are on a 64-bit machine like me, it will be Program Files (x86).       C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client Now let's create some UI for our new project. 5. First, create a new Silverlight User Control called Page3.dyn.xaml 6. Paste the following code into the xaml: <dyn:DynamicPageShim xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:dyn="clr-namespace:DynamicNavigation;assembly=DynamicNavigation"     xmlns:my="clr-namespace:Page3;assembly=Page3">     <my:Page3Host /> </dyn:DynamicPageShim> This is just a 'shim', part of David Poll's technique for dynamic loading. 7. Expand the icon next to Page3.dyn.xaml and delete the code-behind file (Page3.dyn.xaml.cs). 8. Next we will create a control that will 'host' our page. Create another Silverlight User Control called Page3Host.xaml and paste in the following XAML: <dyn:DynamicPage x:Class="Page3.Page3Host"     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:dyn="clr-namespace:DynamicNavigation;assembly=DynamicNavigation"     xmlns:Views="clr-namespace:Page3.Views"      mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400"     Title="Page 3">       <Views:Page3/>   </dyn:DynamicPage> 9. Now paste the following code into the code-behind for this control: using DynamicXAPLoading.Infrastructure;   namespace Page3 {     [PageMetadata(NavigateUri = "/Page3;component/Page3.dyn.xaml", Module = Enums.Page3)]     public partial class Page3Host     {         public Page3Host()         {             InitializeComponent();         }     } } Notice that we are now using that PageMetadata custom attribute class that we created in the Infrastructure project, and setting its two properties. NavigateUri - This tells it that the assembly is called Page3 (with a slash beforehand), and the page we want to load is Page3.dyn.xaml...our 'shim'. That line we added to the UriMapper in MainPage.xaml will use this information to load the page. Module - This goes back to that ModuleEnum class in our Infrastructure project. However, setting the Module to ModuleEnum.Page3 will cause a compilation error, so... 10. Go back to that Enums.cs under the Infrastructure project and add a 3rd entry for Page3: public enum ModuleEnum {     Page1,     Page2,     Page3 } 11. Now right-click on the Page3 project and add a folder called Views. 12. Right-click on the Views folder and create a new Silverlight User Control called Page3.xaml. We won't bother creating a view model for this User Control as I did in the Page 1 and Page 2 projects, just for the sake of simplicity. Feel free to add one if you'd like though, and copy the code from one of those other projects. Right now those view models aren't really doing anything anyway...though they will in my next post. :-) 13. Now let's replace the xaml for Page3.xaml with the following: <dyn:DynamicPage x:Class="Page3.Views.Page3"     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:dyn="clr-namespace:DynamicNavigation;assembly=DynamicNavigation"     mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400"     Style="{StaticResource PageStyle}">       <Grid x:Name="LayoutRoot">         <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">             <StackPanel x:Name="ContentStackPanel">                 <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="Page 3"/>                 <TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}" Text="Page 3 content"/>             </StackPanel>         </ScrollViewer>     </Grid>   </dyn:DynamicPage> 14. And in the code-behind remove the inheritance from UserControl, so it should look like this: namespace Page3.Views {     public partial class Page3     {         public Page3()         {             InitializeComponent();         }     } } One thing you may have noticed is that the base class for the last two User Controls we created is DynamicPage. Once again, we are using the infrastructure that David Poll created. 15. OK, a few last things. We need a link on our main page so that we can access our new page. In MainPage.xaml let's update our links to look like this: <StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">     <HyperlinkButton Style="{StaticResource LinkStyle}" NavigateUri="/Home" TargetName="ContentFrame" Content="home"/>     <Rectangle Style="{StaticResource DividerStyle}"/>     <HyperlinkButton Style="{StaticResource LinkStyle}" Content="page 1" Command="{Binding NavigateCommand}" CommandParameter="{Binding ModulePage1}"/>     <Rectangle Style="{StaticResource DividerStyle}"/>     <HyperlinkButton Style="{StaticResource LinkStyle}" Content="page 2" Command="{Binding NavigateCommand}" CommandParameter="{Binding ModulePage2}"/>     <Rectangle Style="{StaticResource DividerStyle}"/>     <HyperlinkButton Style="{StaticResource LinkStyle}" Content="page 3" Command="{Binding NavigateCommand}" CommandParameter="{Binding ModulePage3}"/> </StackPanel> 16. Next, we need to add the following at the bottom of MainPageViewModel in the ViewModels directory of our DynamicXAPLoading project: public ModuleEnum ModulePage3 {     get { return ModuleEnum.Page3; } } 17. And at last, we need to add a case for our new page to the switch statement in MainPageViewModel: switch (module) {     case ModuleEnum.Page1:         DownloadPackage("Page1.xap");         break;     case ModuleEnum.Page2:         DownloadPackage("Page2.xap");         break;     case ModuleEnum.Page3:         DownloadPackage("Page3.xap");         break;     default:         break; } Now fire up the application and click the page 1, page 2 and page 3 links. What you'll notice is that there is a 2-second delay the first time you hit each page. That is because I added the following line to the Navigate method in MainPageViewModel: Thread.Sleep(2000); // Simulate a 2 second initial loading delay The reason I put this in there is that I wanted to simulate a delay the first time the page loads (as the .xap is being downloaded from the server). You'll notice that after the first hit to the page though that there is no delay...that's because the .xap has already been downloaded. Feel free to comment out this 2-second delay, or remove it if you'd like. I just wanted to show how subsequent hits to the page would be quicker than the initial one. By the way, you may want to display some sort of BusyIndicator while the .xap is loading. I have that in my Task-It appplication, but for the sake of simplicity I did not include it here. In the future I'll blog about how I show and hide the BusyIndicator using events (I'm currently using the eventing framework in Prism for that, but may move to the one in the MVVM Light Toolkit some time soon). Whew, that felt like a lot of steps, but it does work quite nicely. As I mentioned earlier, I'll try to find ways to simplify the code (I'd like to get away from having things like hard-coded .xap file names) and will blog about it in the future if I find a better way. In my next post, I'll talk more about what is actually happening with the code that makes this all work.Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • XAML Parsing Exception

    - by e28Makaveli
    I have a simple XAML page that load fine when it is loaded as part of any application within Visual Studio. However, when I deploy this application using ClickOnce, I get the following exception: Type : System.Windows.Markup.XamlParseException, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Message : Unable to cast object of type 'System.Windows.Controls.Grid' to type 'EMS.Controls.Dictionary.StatusBarControl'. Error at object 'System.Windows.Controls.Grid' in markup file 'EMS.Controls.Dictionary;component/views/statusbarcontrol.xaml'. Source : PresentationFramework Help link : LineNumber : 0 LinePosition : 0 KeyContext : UidContext : NameContext : BaseUri : pack://application:,,,/EMS.Controls.Dictionary;component/views/statusbarcontrol.xaml Data : System.Collections.ListDictionaryInternal TargetSite : Void ThrowException(System.String, System.Exception, Int32, Int32, System.Uri, System.Windows.Markup.XamlObjectIds, System.Windows.Markup.XamlObjectIds, System.Type) Stack Trace : at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType) at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException) at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord) at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord) at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() at System.Windows.Markup.TreeBuilder.Parse() at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at EMS.Controls.Dictionary.StatusBarControl.InitializeComponent() at EMS.Controls.Dictionary.StatusBarControl..ctor(IDataView content) at OCC600.ReportManager.ReportPresenter.ShowQueryView(Object arg, Boolean bringForward, Type selectedDataType) at OCC600.ReportManager.ReportPresenter..ctor(IUnityContainer container) at OCC600.ReportManager.Module.Initialize() at Microsoft.Practices.Composite.Modularity.ModuleLoader.Initialize(ModuleInfo[] moduleInfos) Inner Exception --------------- Type : System.InvalidCastException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Unable to cast object of type 'System.Windows.Controls.Grid' to type 'EMS.Controls.Dictionary.StatusBarControl'. Source : EMS.Controls.Dictionary Help link : Data : System.Collections.ListDictionaryInternal TargetSite : Void System.Windows.Markup.IComponentConnector.Connect(Int32, System.Object) Stack Trace : at EMS.Controls.Dictionary.StatusBarControl.System.Windows.Markup.IComponentConnector.Connect(Int32 connectionId, Object target) at System.Windows.Markup.BamlRecordReader.ReadConnectionId(BamlConnectionIdRecord bamlConnectionIdRecord) at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord) The XAML page is given below: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cdic="clr-namespace:EMS.Controls.Dictionary.Primitives" xmlns:dicutil="clr-namespace:OCC600.Infrastructure.Dictionary.Utility;assembly=EMS.Infrastructure.Dictionary" Loaded="ResultSetControl_Loaded" <StatusBarItem Margin="10,0, 10, 0"> <TextBlock Text="{Binding CountText}" Padding="5,0"/> </StatusBarItem> <StatusBarItem Margin="10,0"> <TextBlock Text="{Binding MemoryUsageText}" Padding="5,0"/> </StatusBarItem> <StatusBarItem Margin="10,0" MaxWidth="400"> <TextBlock Text="{Binding StatusReport.Summary}" Padding="5,0" /> </StatusBarItem> <ProgressBar Margin="20,0" Name="progBar" Width="150" Height="13" Visibility="Collapsed" > <ProgressBar.ContextMenu> <ContextMenu Name="ctxMenu" ItemsSource="{Binding ActiveWorkItems}" Visibility="{Binding Path=ActiveWorkItems.HasItems, Converter={StaticResource BooToVisConv}}"> <ContextMenu.ItemContainerStyle> <Style TargetType="{x:Type MenuItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type MenuItem}"> <StackPanel Height="20" Margin="10,0" Orientation="Horizontal" HorizontalAlignment="Left"> <TextBlock Text="{Binding Path=Name, Mode=OneTime}" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Left" /> <ToggleButton Style="{StaticResource vistaGoldenToggleButtonStyle}" Padding="5,0" Content="Cancel" IsChecked="{Binding Cancel}" Margin="10,0,0,0" > </ToggleButton> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> </ContextMenu.ItemContainerStyle> </ContextMenu> </ProgressBar.ContextMenu> </ProgressBar> <StatusBarItem Margin="10,0" MaxWidth="400" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Last Update:" Padding="5,0" /> <TextBlock Text="{Binding TimeStamp}" Padding="5,0" /> </StackPanel> </StatusBarItem> <!-- TODO: Put checkmark if all is well, or error if connection failed--> <StatusBarItem Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=dc:Ribbon, ResourceId=StatusBarItemAlt}}" DockPanel.Dock="Right" Padding="6,0,32,0" > <cdic:SplitButton Margin="5,0" Padding="5,2" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type cdic:SplitButtonResources}, ResourceId=vistaSplitButtonStyle}}" Mode="Split"> <cdic:SplitButton.ContextMenu> <ContextMenu > <MenuItem Header="Refresh Now" Command="{Binding ToggleConnectivityCmd}" CommandParameter="false"/> <MenuItem IsCheckable="True" IsChecked="{Binding ConnectState, Converter={StaticResource isFailedConverter}}" CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=IsChecked}" Header="Work Offline" Command="{Binding ToggleConnectivityCmd}"/> </ContextMenu> </cdic:SplitButton.ContextMenu> <cdic:SplitButton.Content> <StackPanel Orientation="Horizontal"> <Image x:Name="img" Source="{Binding ConnectState, Converter={StaticResource imageConverter}}" Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock Text="{Binding ConnectState}" Padding="3,0,0,0"/> </StackPanel> </cdic:SplitButton.Content> </cdic:SplitButton> </StatusBarItem> </StatusBar> </Grid> The error just seems to have come out of no where. Any ideas? TIA.

    Read the article

  • WPF: HierarchicalDataTemplate ItemsPanel

    - by Echilon
    I have a TreeView which uses a custom ItemsPanel to show the first level of items in a StackPanel, but I need to show subitems in a StackPanel too. The problem is, the second level of items are shown in a WrapPanel, and as HierarchicalDataTemplate doesn't have an itemsPanel property I'm not sure how to do this. This is my xaml: <TreeView x:Name="treGlobalCards"> <TreeView.ItemsPanel> <ItemsPanelTemplate> <StackPanel IsItemsHost="True" Orientation="{Binding Orientation,RelativeSource={x:Static RelativeSource.TemplatedParent}}" MaxWidth="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"/> </ItemsPanelTemplate> </TreeView.ItemsPanel> <TreeView.ItemTemplate> <HierarchicalDataTemplate x:Key="CardTypeTemplate" ItemsSource="{Binding Cards}"> <TextBlock Text="{Binding Path=CardType}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView>

    Read the article

  • Wpf nesting containers

    - by dortzur
    On a window control, my main container is a grid. My grid has 2 rows, one row definition is 50*, and the other is 250*. Now i want to add a right sidebar, lets say with a StackPanel. I would like to have a ListBox inside the StackPanel that aligns with the 50* grid row, so as the window height gets bigger, the ListBox size will also get bigger. My question is whether i can achieve this behavior while the ListBox is inside the StackPanel (which is nested inside the grid) or must the ListBox be placed directly inside the grid?

    Read the article

  • [WPF] selected item in listbox unreadable because of the color !

    - by Anna
    I dynamically create a collection of stackpanels in my listbox. In this stackpanel are contained labels and checkbox horizontally aligned. The problem is when I click on a stackpanel, the selection is unreadable because the line become dark-blue whereas the letters stay black so black on blue, you see nothing... how can I dynamically change the forecolor of the selected elements in the stackpanel ? I say dynamically and not in the xml file, because all those elements are dynamically created, base on a database... thanksssss!!

    Read the article

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