Search Results

Search found 322 results on 13 pages for 'fontsize'.

Page 12/13 | < Previous Page | 8 9 10 11 12 13  | Next Page >

  • WPF ComboBox in Grid Issue

    - by Nathan
    I am trying to put a series of comboboxes in a grid and then I bind them to a list. For some reason unknown to me when I click the open button on the combobox nothing happens. If I move a comobobox outside the grid it opens just fine. Can someone please tell me what I am doing wrong here. It has to be something stupid because I've used comoboxes before just fine. Here is my xaml: <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <GroupBox Header="Download Critera" Margin="70,30" Name="groupBox1" Grid.RowSpan="2"> <Grid Height="Auto" Name="grid1" Width="Auto" Margin="0" IsHitTestVisible="False"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Grid.Row="1" Margin="10,5,5,5" Name="textBlock1" Text="A:" Foreground="Black" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" /> <TextBlock Grid.Row="2" Margin="10,5,5,5" Name="textBlock2" Text="B:" Foreground="Black" VerticalAlignment="Center" FontWeight="Bold" /> <TextBlock Grid.Row="3" Margin="10,5,5,5" Name="textBlock3" Text="C:" Foreground="Black" VerticalAlignment="Center" FontWeight="Bold" /> <TextBlock Grid.Row="4" Margin="10,5,5,5" Name="textBlock4" Foreground="Black" Text="D:" VerticalAlignment="Center" FontWeight="Bold" /> <TextBlock Grid.Row="5" Margin="10,5,5,5" Name="textBlock5" Text="E:" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" /> <ComboBox x:Name="cb1" Grid.Column="1" Grid.Row="1" Margin="5" MaxDropDownHeight="100" ItemsSource="{Binding Projects}"/> <ComboBox x:Name="cb2" Grid.Column="1" Grid.Row="2" Margin="5" MaxDropDownHeight="100" ItemsSource="{Binding Projects}"/> <ComboBox x:Name="cb3" Grid.Column="1" Grid.Row="3" Margin="5" MaxDropDownHeight="100" ItemsSource="{Binding Projects}"/> <ComboBox x:Name="cb4" Grid.Column="1" Grid.Row="4" Margin="5" MaxDropDownHeight="100" ItemsSource="{Binding Projects}"/> <ComboBox x:Name="cb5" Grid.Column="1" Grid.Row="5" Margin="5" MaxDropDownHeight="100" ItemsSource="{Binding Projects}"/> </Grid> </GroupBox> </Grid>

    Read the article

  • Qt4: QPrinter / QPainter only print the first document

    - by hurikhan77
    In Qt4, I'm initializing the printer in the main.cpp in the following way: mw->printer = new QPrinter(QPrinter::HighResolution); mw->printer->setPaperSize(QPrinter::A5); mw->printer->setNumCopies(2); mw->printer->setColorMode(QPrinter::GrayScale); QPrintDialog *dialog = new QPrintDialog(mw->printer, mw); dialog->setWindowTitle(QObject::tr("Printer Setup")); if (dialog->exec() == QDialog::Accepted) { mw->printer->setFullPage(TRUE); return a.exec (); } This works fine for printing the first document from the application: qDebug("Printing"); QPainter p; if (!p.begin(printer)) { qDebug("Printing aborted"); return; } Q3PaintDeviceMetrics metrics(p.device()); int dpiy = metrics.logicalDpiY(); int dpix = metrics.logicalDpiX(); int tmargin = (int) ((marginTop / 2.54) * dpiy); int bmargin = (int) ((marginBottom / 2.54) * dpiy); int lmargin = (int) ((marginLeft / 2.54) * dpix); int rmargin = (int) ((marginRight / 2.54) * dpix); QRect body(lmargin, tmargin, metrics.width() - (lmargin + rmargin), metrics.height() - (tmargin + bmargin)); QString document; /* ... app logic to write a richtext document */ Q3SimpleRichText richText(QString("<qt>%1</qt>").arg(document), QFont("Arial", fontSize)); richText.setWidth(&p, body.width()); QRect view(body); int page = 1; do { // draw text richText.draw(&p, body.left(), body.top(), view, colorGroup()); view.moveBy(0, body.height()); p.translate(0, -body.height()); // insert page number p.drawText(view.right() - p.fontMetrics().width(QString::number(page)), view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page)); // exit loop on last page if (view.top () >= richText.height ()) break; printer->newPage(); page++; } while (TRUE); if (!p.end()) qDebug("Print painter yielded failure"); But when this routine runs the second time, it does not print the document. It will just print an empty page but still with the page number on it. This worked fine before with Qt3.

    Read the article

  • Windowsless property is not working in Firefox ONLY

    - by lmenaria
    Hello, I have created a simple silverlight application to display some text at realtime from xml. The text display using HTML DIV tag. I have added plugin property windowless=true, enablehtmlaccess=true,background=transparent. On Silverlight I have added a Button "Continue" at Top & Bottom, which shows some message on that click. Silverlight Plugin resize based in XML contents. My code : MainPage.xaml: MainPage.xaml.cs: Creating HTML DIV on Application Start using : HtmlDocument _document = HtmlPage.Document; HtmlElement iDIV = _document.CreateElement("DIV"); iDIV.SetAttribute("id", "divHTMLViewer"); iDIV.SetStyleAttribute("position", "absolute"); iDIV.SetStyleAttribute("z-index", "1"); iDIV.SetStyleAttribute("display", "INLINE"); iDIV.SetStyleAttribute("top", "100px"); iDIV.SetStyleAttribute("height", "0px"); iDIV.SetStyleAttribute("width", "96%"); iDIV.SetStyleAttribute("left", "15px"); iDIV.SetStyleAttribute("text-align", "justify"); HtmlElement body = _document.GetElementsByTagName("BODY")[0] as HtmlElement; body.RemoveChild(iDIV); body.AppendChild(iDIV); Set the XML text : HtmlElement divHTMLViewer = HtmlPage.Document.GetElementById("divHTMLViewer"); sText = sText.Replace("<", "<").Replace(">", ""); divHTMLViewer.SetStyleAttribute("display", "none"); divHTMLViewer.SetStyleAttribute("width", "96%"); divHTMLViewer.SetStyleAttribute("top", "100px"); divHTMLViewer.SetStyleAttribute("left", "15px"); divHTMLViewer.RemoveStyleAttribute("color"); divHTMLViewer.RemoveStyleAttribute("fontSize"); divHTMLViewer.SetProperty("innerHTML", sText); divHTMLViewer.SetStyleAttribute("display", "INLINE"); setSilverlightControlHeight(UILAYOUT.INSTRUCTIONS); Silverlight Plugin size increase code : isilverlightControlHost.SetStyleAttribute("height", HtmlPage.Window.Eval("document.documentElement.scrollHeight").ToString() + "px"); isilverlightControlHost.SetStyleAttribute("position", "absolute"); All these code is working fine in Internet Explorer, Crome & Safari but "Continue" not visible in FIREFOX ONLY. So is there any issue with this code ? Code Sample :http://lm-bucket-for-forum-post.s3.amazonaws.com/HtMLViewerSilverLight.zip working sample : Just replace ".zip" with "TestPage.html" in above URL. Please let me know how can I solve it ? Thanks in advance, Laxmilal Menaria

    Read the article

  • WPF Linear Fill

    - by Ben
    Hi, I have found some example code that creates a gradient fill in a WPF rectangle control: <Rectangle Height="{Binding ElementName=txtName}" Width="{Binding ElementName=txtName}"> <Rectangle.Fill> <LinearGradientBrush> <GradientStop Color="Silver" Offset="0.0" /> <GradientStop Color="Black" Offset="0.5" /> <GradientStop Color="white" Offset="1.0" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> I have some written some code that displays a collection of ListBox's that contain details from MyObject: <UserControl.Resources> <DataTemplate x:Key="CustomerTemplate"> <Border BorderThickness="2" BorderBrush="Silver" CornerRadius="5" Padding="1" Height="50"> <Grid x:Name="thisGrid"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <StackPanel Orientation="Horizontal" > <Image Source="C:\MyImage.jpg" Height="50" Width="100" ></Image> </StackPanel> <Border Grid.Column="1" Margin="0" Padding="0"> <StackPanel Orientation="Vertical"> <TextBlock Name="txtName" Text="{Binding Name}" Background="Silver" Foreground="Black" FontSize="16" FontWeight="Bold" Height="25"/> </StackPanel> </Border> </Grid> </Border> </DataTemplate> </UserControl.Resources> <ListBox ItemsSource="{Binding}" ItemTemplate="{StaticResource CustomerTemplate}" Name="grdList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" > </ListBox> I would like to apply the same stlye of fill that i get with the first example, in each of my ListBox's. I can't quite figure out how to do this. Can anyone help? Thanks

    Read the article

  • WPF performance for large number of elements on the screen

    - by Mark
    Im currently trying to create a Scene in WPF where I have around 250 controls on my screen and the user can Pan and Zoom in and out of these controls using the mouse. I have run the WPF Performance Suite tools on the application when there are a large number of these controls on the screen (i.e. when the user has zoomed right out) the FPS drops down to around 15 which is not very good. Here is the basic outline of the XAML: <Window> <Window.Resources> <ControlTemplate x:Key="LandTemplate" TargetType="{x:Type local:LandControl}"> <Canvas> <Path Fill="White" Stretch="Fill" Stroke="Black" StrokeThickness="1" Width="55.5" Height="74.687" Data="M0.5,0.5 L55,0.5 L55,74.187 L0.5,74.187 z"/> <Canvas x:Name="DetailLevelCanvas" Width="24.5" Height="21" Canvas.Left="15.306" Canvas.Top="23.972"> <TextBlock Width="21" Height="14" Text="712" TextWrapping="Wrap" Foreground="Black"/> <TextBlock Width="17.5" Height="7" Canvas.Left="7" Canvas.Top="14" Text="614m2" TextWrapping="Wrap" FontSize="5.333" Foreground="Black"/> </Canvas> </Canvas> </ControlTemplate> </Window.Resources> ... <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx"> <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx"> <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx"> <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx"> ... and so on... </Window> Ive tried to minimise the details in the control template and I even did a massive find and replace of the controls to just put their raw elements inline instead of using a template, but with no noticeable performance improvements. I have seen other SO questions about this and people say to do custom drawing, but I dont really see how that make sense when you have to zoom and pan like I do. If anyone can help out here, that would be great! Mark

    Read the article

  • Programmatically Setting ControlTemplate Item

    - by Robert
    I'm having trouble figuring out how to programmatically setting the "Stroke" of my arrow. I'm using these buttons in a menu bar and I want the one currently selected to have it's arrow change to green and all the others gray. <Style x:Key="FooterGrayButtonStyle" TargetType="{x:Type Button}"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="MinHeight" Value="35" /> <Setter Property="FontSize" Value="16"/> <Setter Property="Margin" Value="0,5,10,5" /> <Setter Property="Foreground" Value="White" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Border x:Name="Bd" Background="#FF535A65" BorderBrush="Black" BorderThickness="1" CornerRadius="10"> <Path x:Name="arrow" Stretch="Fill" Stroke="#FFB1BB1C" StrokeThickness="5" HorizontalAlignment="Right" Margin="5" StrokeEndLineCap="Round" StrokeStartLineCap="Round" StrokeLineJoin="Miter" Width="13" Height="23" Data="M0,0 L1,1 0,2" /> </Border> <ContentPresenter HorizontalAlignment="Left" Margin="15,-2,30,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="Bd" Property="Background" Value="#FFB1BB1C" /> <Setter Property="Stroke" TargetName="arrow" Value="White"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Stroke" TargetName="arrow" Value="#FFB7B7B7"/> <Setter Property="Foreground" Value="#FFB7B7B7"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>

    Read the article

  • Stretch panel with splitter

    - by user1153896
    I want to implement a basic WPF layout with three panels and two splitters (Horizontal and Vertical splitter). Two panels on the left and on the bottom has to be callapsable and one panel has to stretch accordingly. Here is a simple XAML: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel Background="Aqua" Grid.Column="0" Name="leftPanel" > <TextBlock FontSize="35" Foreground="#58290A" TextWrapping="Wrap">Left Hand Side</TextBlock> </StackPanel> <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch"/> <Grid Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="5" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Label Content="... Clien Area .. Has to Stretch vertically and horizontally" Margin="10"></Label> <Button Click="LeftButton_Click" Margin="10">Close Left Panel</Button> <Button Click="BottomButton_Click" Margin="10">Close Bottom Panel</Button> </StackPanel> <GridSplitter Grid.Row="1" Background="Gray" HorizontalAlignment="Stretch"/> <ListBox Grid.Row="2" Background="Violet" Name="bottomPanel"> <ListBoxItem>Hello</ListBoxItem> <ListBoxItem>World</ListBoxItem> </ListBox> </Grid> </Grid> and codebehind: private void LeftButton_Click(object sender, RoutedEventArgs e) { leftPanel.Visibility = (leftPanel.Visibility == System.Windows.Visibility.Visible)? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible; } private void BottomButton_Click(object sender, RoutedEventArgs e) { bottomPanel.Visibility = (bottomPanel.Visibility == System.Windows.Visibility.Visible) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible; } This code doesn't work as expected :(. Any WPF experts around? to suggest a solution for having Client Area (stretched) and splitter at the same time? DockPanel will work perfectly, but I need splitter! Thanks.

    Read the article

  • Bind Icon depending on Enum in WPF Treeview

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

    Read the article

  • ScrollViewer in a ListBox not working. WPF.

    - by guest
    Hi, I have the following defined in my control: <local:TestListBox.ItemTemplate> <DataTemplate> <Border x:Name="eventBorder" Width="{Binding ElementName=eventsLbx, Path=ActualWidth,BorderBrush="{Binding Color}" BorderThickness="1" CornerRadius="4"> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop x:Name="StartGradient" Color="#FFFFFFFF" Offset="0"/> <GradientStop x:Name="EndGradient" Color="{Binding Color}" Offset="1"/> </LinearGradientBrush> </Border.Background> <Border.ToolTip> <ToolTip Content="{Binding Text}"/> </Border.ToolTip> <TextBlock TextTrimming="CharacterEllipsis" HorizontalAlignment="Center" FontSize="12" Text="{Binding Text}" /> </Border> <DataTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="eventBorder" Property="Background" Value="#FFE4EBF5"/> </Trigger> </DataTemplate.Triggers> --> </DataTemplate> </local:TestListBox.ItemTemplate> </local:TestListBox> </ScrollViewer.Content> </ScrollViewer> </Grid> <ControlTemplate.Triggers> <Trigger SourceName="eventsLbx" Property="HasItems" Value="False"> <Setter TargetName="eventsLbx" Property="Visibility" Value="Hidden"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> Now if there are more items than are visible, then the scrollviewer appears properly but the user CANNOT drag the scrollviewer middle button for scrolling. The user can click on the arrows at the end of the scrollviewer to scroll but he cannot click the bar that appears on the scrollbar and drag it to actually scroll the contents. I cannot figure out why this is happening...

    Read the article

  • ListBox content does not resize when window is made smaller

    - by DamonGant
    I'm using .NET 4.0 (not .NET 4.0 CP) and have run into this kinda unique issue. I created a ListBox to display bound elements, first off here is (a part) of my XAML. <Grid Grid.Row="2" Background="#EEEEEE"> <Border Margin="6,10,10,10" BorderBrush="#666666" BorderThickness="1"> <ListBox ItemsSource="{Binding}" Name="appList" BorderThickness="0" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="80" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Border Grid.Column="0" Margin="5" BorderThickness="3" CornerRadius="2" BorderBrush="Black" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="ItemBorder"> <Image Width="64" Height="64" Source="{Binding Path=IconUri}" Stretch="UniformToFill" /> </Border> <StackPanel Margin="0,5,5,5" Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Stretch"> <TextBlock FontSize="18" Text="{Binding Path=DisplayName}" /> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="60"/> </Grid.ColumnDefinitions> <ProgressBar Grid.Column="0" Height="24" HorizontalAlignment="Stretch" IsIndeterminate="{Binding Path=IsDiscovering}" Value="{Binding Path=PercentageDownloaded}" /> <TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"><TextBlock x:Name="percentageDownloaded" /><TextBlock x:Name="percentageMeter">%</TextBlock></TextBlock> </Grid> </StackPanel> </Grid> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=IsDiscovering}"> <DataTrigger.Value>True</DataTrigger.Value> <Setter TargetName="percentageDownloaded" Property="Text" Value="N/A" /> <Setter TargetName="percentageMeter" Property="Visibility" Value="Collapsed" /> </DataTrigger> <DataTrigger Binding="{Binding Path=IsDiscovering}"> <DataTrigger.Value>False</DataTrigger.Value> <Setter TargetName="percentageDownloaded" Property="Text" Value="{Binding Path=PercentageDownloaded}" /> <Setter TargetName="percentageMeter" Property="Visibility" Value="Visible" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </ItemsControl.ItemTemplate> </ListBox> </Border> </Grid> Sizing the window up stretches the ListBox content just fine, but when I size it down, it retains it's width and spawns vertical scrollbars.

    Read the article

  • How can I change the TreeView Icon into a folder icon?

    - by KDP
    I'm trying to change the icon of my TreeView in a folder icon. Also when it collapses it needs to have an opened folder icon. My treeview has databound items in it and the code is: <TreeView x:Name="TreeViewCategories" Grid.Row="0" Grid.Column="1" Height="610" HorizontalAlignment="Left" Margin="29,111,0,0" VerticalAlignment="Top" Width="315" BorderThickness="0" Background="Transparent" > <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Items}"> <TextBlock FontSize="20" Text="{Binding Name}" PreviewMouseDown="TextBlock_PreviewMouseDown"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> Also this is how I fill the treeview with items from XML (It's a snipped out of alot of code: private void LoadHospitalXML() { try { FileStream fs = new FileStream("ConfigOrgHospital.xml", FileMode.Open, FileAccess.Read); var xml = XmlReader.Create(fs); rootElement = ConvertHospitalData(xml); this.TreeViewCategories.ItemsSource = null; List<HospitalWrapper> li = new List<HospitalWrapper>(); var hosp = rootElement.Items.FirstOrDefault(); if (hosp != null) { foreach (var i in hosp.Hospital) { li.AddIfNotNull(CreateHospList(i)); } } this.TreeViewCategories.ItemsSource = li; } catch (Exception e) { MessageBox.Show(e.Message); } } private HospitalWrapper CreateHospList(object obj) { var newItem = new HospitalWrapper(); newItem.Context = obj; //Hospital Names// if (obj is HospitalDataHospitalsHospital) { var hosp = (HospitalDataHospitalsHospital)obj; //newItem.Title = "Hospitals"; newItem.Name = hosp.DefaultName; var tmp = new HospitalWrapper(); tmp.Name = "Sites"; tmp.IsTitle = true; if (hosp.Sites != null) foreach (var i in hosp.Sites) { tmp.Items.AddIfNotNull(CreateHospList(i)); } newItem.Items.Add(tmp); tmp = new HospitalWrapper(); tmp.Name = "Specialties"; tmp.IsTitle = true; if (hosp.Deps != null) foreach (var j in hosp.Deps) { tmp.Items.AddIfNotNull(CreateHospList(j)); } newItem.Items.Add(tmp); } }

    Read the article

  • Not able to select a row in my ListView

    - by Krishna Thota
    I'm not able to select a row in my list Item Here is my code <Grid DockPanel.Dock="Left" MinWidth="250"> <ListView x:Name="ListVendors" ItemsSource="{Binding SourceCollection}"> <ListView.View> <GridView> <GridView.ColumnHeaderContainerStyle> <Style><Setter Property="FrameworkElement.Visibility" Value="Collapsed"/></Style> </GridView.ColumnHeaderContainerStyle> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding Name}" FontSize="20"/> <TextBlock Grid.Row="1" Text="{Binding Code}" Foreground="Gray" /> <TextBlock Grid.Row="2" Text="{Binding ContactNo}" Foreground="Gray" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding Path=Address, Converter={StaticResource addNewLineConv}}" Grid.RowSpan="3" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="2" Text="{Binding Email}"/> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn DisplayMemberBinding="{Binding Email}" Header="Email"/> </GridView> </ListView.View> </ListView> How can I select a row in this ListView?

    Read the article

  • How to add Items to GridView in C# Windows Store App (Win8)

    - by flexage
    To keep things simple let's just say I have a c# Windows Store Project for Windows 8 that has the following items: GridView (PlatformsGrid) List«PlatformSearchResult» (allPlatforms) DataTemplate (PlatformDataTemplate) in standardstyles.xaml allPlatforms is a collection of "PlatformSearchResult"objects populated from an online API, and has the following 3 properties: ID Name Alias I am able to add a new item to the gridview for each object that exists in my allPlatforms collection, however the items are blank and do not show the data from my objects. A quick summary of the current code looks like this: XAML Markup: <!-- Platforms Content --> <GridView x:Name="PlatformsGrid" Grid.Row="1" CanReorderItems="True" CanDragItems="True" ItemTemplate="{StaticResource PlatformDataTemplate}" > <GridView.ItemsPanel> <ItemsPanelTemplate> <WrapGrid MaximumRowsOrColumns="2" VerticalChildrenAlignment="Top" HorizontalChildrenAlignment="Center" /> </ItemsPanelTemplate> </GridView.ItemsPanel> </GridView> Data Template <!-- Platform Item Template --> <DataTemplate x:Key="PlatformDataTemplate"> <Grid Background="#FF939598" Height="250" Width="250"> <Image Source="/SampleImage.png" Stretch="UniformToFill"/> <StackPanel Orientation="Vertical" Background="#CC000000" Height="90" VerticalAlignment="Bottom"> <TextBlock Text="{Binding Name}" Margin="10,3,0,0" Width="242" Height="62" TextTrimming="WordEllipsis" TextWrapping="Wrap" HorizontalAlignment="Left"/> <TextBlock Text="{Binding Alias}" Margin="10,2,0,0" Width="186" Height="14" TextTrimming="WordEllipsis" HorizontalAlignment="Left" FontSize="9" Opacity="0.49"/> </StackPanel> </Grid> </DataTemplate> Controlling Function private async void FetchItemInfo_Loaded(object sender, RoutedEventArgs e) { // Get List of Top Games List<PlatformSearchResult> allPlatforms = new List<PlatformSearchResult>(); allPlatforms = await GamesDB.GetPlatforms(); // Dynamically Create Platform Tiles foreach (PlatformSearchResult platform in allPlatforms) { PlatformsGrid.DataContext = platform; PlatformsGrid.Items.Add(platform); } } How do I get the added items to show the appropriate object properties (ignoring the image for now), I'm just interested in populating the content of the TextBlocks. I appreciate any help anyone can provide! Thanks, Alex.

    Read the article

  • customizing item renderer

    - by BretzelPretzel
    i would like the label and message to be on the left of the icon....i would also like the icon to be right-aligned what is the best way to do this? I'm confused by some of the tutorials i'm seeing for custom item renderers since they never explain how to format the renderer mxml, so i haven't figured that out yet although i suspect that's what i need to be doing <?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:components="components.*" creationComplete="imagelistings.send()" title="{data.title}"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.events.FlexEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import spark.events.IndexChangeEvent; import valueObjects.imagelistingclass; [Bindable] private var listings:ArrayCollection = new ArrayCollection(); protected function toursService_resultHandler(event:ResultEvent):void { var listingarray:ArrayCollection=event.result.Chapter1.entry; var entry:imagelistingclass; for each(var plate:Object in listingarray) { entry=new imagelistingclass(); entry.image=plate.image; entry.location=plate.location; entry.html=plate.html; listings.addItem(entry); } } ]]> </fx:Script> <fx:Declarations> <s:HTTPService id="imagelistings" result="toursService_resultHandler(event)" url="assets/chapter1info.xml"/> </fx:Declarations> <s:List id="theList" left="0" right="0" top="0" bottom="0" alternatingItemColors="#000000" contentBackgroundColor="#404040" dataProvider="{listings}" horizontalScrollPolicy="off" > <s:itemRenderer> <fx:Component> <s:IconItemRenderer color="#FFFFFF" fontSize="30" iconField="location" labelField="" iconFillMode="scale" iconScaleMode="letterbox" iconHeight="125" messageField="image"> </s:IconItemRenderer> </fx:Component> </s:itemRenderer> </s:List>

    Read the article

  • Silverlight for Windows Embedded Tutorial (step 5 and a bit of Windows Phone 7)

    - by Valter Minute
    If you haven’t spent the last week in the middle of the Sahara desert or traveling on a sled in the north pole area you should have heard something about the launch of Windows Phone 7 Series (or Windows Phone Series 7, or Windows Series Phone 7 or something like that). Even if you are in the middle of the desert or somewhere around the north pole you may have been reached by the news, since it seems that WP7S (using the full name will kill my available bandwidth!) is generating a lot of buzz in the development and IT communities. One of the most important aspects of this new platform is that it will be programmed using a new set of tools and frameworks, completely different from the ones used on older releases of Windows Mobile (or SmartPhone, or PocketPC or whatever…). WP7S applications can be developed using Silverlight or XNA. If you want to learn something more about WP7S development you can download the preview of Charles Petzold’s book about it: http://www.charlespetzold.com/phone/index.html Charles Petzold is also the author of “Programming Windows”, the first book I ever read about programming on Windows (it was Windows 3.0 at that time!). The fact that even I was able to learn how to develop Windows application is a proof of the quality of Petzold’s work. This book is up to his standards and the 150pages preview is already rich in technical contents without being boring or complicated to understand. I may be able to become a Windows Phone developer thanks to mr. Petzold. Mr. Petzold uses some nice samples to introduce the basic concepts of Silverlight development on WP7S. On this new platform you’ll use managed code to develop your application, so those samples can’t be ported on Windows CE R3 as they are, but I would like to take one of the first samples (called “SilverlightTapHello1”) and adapt it to Silverlight for Windows Embedded to show that even plain old native code can be used to develop “cool” user interfaces! The sample shows the standard WP7S title header and a textbox with an hello world message inside it. When the user touches the textbox, it will change its color. When the user touches the background (Grid) behind it, its default color (plain old White) will be restored. Let’s see how we can implement the same features on our embedded device! I took the XAML code of the sample (you can download the book samples here: http://download.microsoft.com/download/1/D/B/1DB49641-3956-41F1-BAFA-A021673C709E/CodeSamples_DRAFTPreview_ProgrammingWindowsPhone7Series.zip) and changed it a little bit to remove references to WP7S or managed runtime. If you compare the resulting files you will see that I was able to keep all the resources inside the App.xaml files and the structure of  MainPage.XAML almost intact. This is the Silverlight for Windows Embedded version of MainPage.XAML: <UserControl x:Class="SilverlightTapHello1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" Width="640" Height="480">   <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions>   <!--TitleGrid is the name of the application and page title--> <Grid x:Name="TitleGrid" Grid.Row="0"> <TextBlock Text="SILVERLIGHT TAP HELLO #1" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}"/> <TextBlock Text="main page" x:Name="textBlockListTitle" Style="{StaticResource PhoneTextPageTitle2Style}"/> </Grid>   <!--ContentGrid is empty. Place new content here--> <Grid x:Name="ContentGrid" Grid.Row="1" MouseLeftButtonDown="ContentGrid_MouseButtonDown" Background="{StaticResource PhoneBackgroundBrush}"> <TextBlock x:Name="TextBlock" Text="Hello, Silverlight for Windows Embedded!" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </Grid> </UserControl> If you compare it to the WP7S sample (not reported here to avoid any copyright issue) you’ll notice that I had to replace the original phoneNavigation:PhoneApplicationPage with UserControl as the root node. This make sense because there is not support for phone applications on CE 6. I also had to specify width and height of my main page (on the WP7S device this will be adjusted by the OS) and I had to replace the multi-touch event handler with the MouseLeftButtonDown event (no multitouch support for Windows CE R3, still). I also changed the hello message, of course. I used XAML2CPP to generate the boring part of our application and then added the initialization code to WinMain: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { if (!XamlRuntimeInitialize()) return -1;   HRESULT retcode;   IXRApplicationPtr app; if (FAILED(retcode=GetXRApplicationInstance(&app))) return -1; XRXamlSource dictsrc;   dictsrc.SetResource(hInstance,TEXT("XAML"),IDR_XAML_App);   if (FAILED(retcode=app->LoadResourceDictionary(&dictsrc,NULL))) return -1;   MainPage page;   if (FAILED(page.Init(hInstance,app))) return -1;   UINT exitcode;   if (FAILED(page.GetVisualHost()->StartDialog(&exitcode))) return -1;   return exitcode; }   You may have noticed that there is something different from the previous samples. I added the code to load a resource dictionary. Resources are an important feature of XAML that allows you to define some values that could be replaced inside any XAML file loaded by the runtime. You can use resources to define custom styles for your fonts, backgrounds, controls etc. and to support internationalization, by providing different strings for different languages. The rest of our WinMain isn’t that different. It creates an instances of our MainPage object and displays it. The MainPage class implements an event handler for the MouseLeftButtonDown event of the ContentGrid: class MainPage : public TMainPage<MainPage> { public:   HRESULT ContentGrid_MouseButtonDown(IXRDependencyObject* source,XRMouseButtonEventArgs* args) { HRESULT retcode; IXRSolidColorBrushPtr brush; IXRApplicationPtr app;   if (FAILED(retcode=GetXRApplicationInstance(&app))) return retcode;   if (FAILED(retcode=app->CreateObject(IID_IXRSolidColorBrush,&brush))) return retcode;   COLORREF color=RGBA(0xff,0xff,0xff,0xff);   if (args->pOriginalSource==TextBlock) color=RGBA(rand()&0xFF,rand()&0xFF,rand()&0xFF,0xFF);   if (FAILED(retcode=brush->SetColor(color))) return retcode;   if (FAILED(retcode=TextBlock->SetForeground(brush))) return retcode; return S_OK; } }; As you can see this event is generated when a used clicks inside the grid or inside one of the objects it contains. Since our TextBlock is inside the grid, we don’t need to provide an event handler for its MouseLeftButtonDown event. We can just use the pOriginalSource member of the event arguments to check if the event was generated inside the textblock. If the event was generated inside the grid we create a white brush,if it’s inside the textblock we create some randomly colored brush. Notice that we need to use the RGBA macro to create colors, specifying also a transparency value for them. If we use the RGB macro the resulting color will have its Alpha channel set to zero and will be transparent. Using the SetForeground method we can change the color of our control. You can compare this to the managed code that you can find at page 40-41 of Petzold’s preview book and you’ll see that the native version isn’t much more complex than the managed one. As usual you can download the full code of the sample here: http://cid-9b7b0aefe3514dc5.skydrive.live.com/self.aspx/.Public/SilverlightTapHello1.zip And remember to pre-order Charles Petzold’s “Programming Windows Phone 7 series”, I bet it will be a best-seller! Technorati Tags: Silverlight for Windows Embedded,Windows CE

    Read the article

  • Silverlight MEF – Download On Demand

    - by PeterTweed
    Take the Slalom Challenge at www.slalomchallenge.com! A common challenge with building complex applications in Silverlight is the initial download size of the xap file.  MEF enables us to build composable applications that allows us to build complex composite applications.  Wouldn’t it be great if we had a mechanism to spilt out components into different Silverlight applications in separate xap files and download the separate xap file only if needed?   MEF gives us the ability to do this.  This post will cover the basics needed to build such a composite application split between different silerlight applications and download the referenced silverlight application only when needed. Steps: 1.     Create a Silverlight 4 application 2.     Add references to the following assemblies: System.ComponentModel.Composition.dll System.ComponentModel.Composition.Initialization.dll 3.     Add a new Silverlight 4 application called ExternalSilverlightApplication to the solution that was created in step 1.  Ensure the new application is hosted in the web application for the solution and choose to not create a test page for the new application. 4.     Delete the App.xaml and MainPage.xaml files – they aren’t needed. 5.     Add references to the following assemblies in the ExternalSilverlightApplication project: System.ComponentModel.Composition.dll System.ComponentModel.Composition.Initialization.dll 6.     Ensure the two references above have their Copy Local values set to false.  As we will have these two assmblies in the original Silverlight application, we will have no need to include them in the built ExternalSilverlightApplication build. 7.     Add a new user control called LeftControl to the ExternalSilverlightApplication project. 8.     Replace the LayoutRoot Grid with the following xaml:     <Grid x:Name="LayoutRoot" Background="Beige" Margin="40" >         <Button Content="Left Content" Margin="30"></Button>     </Grid> 9.     Add the following statement to the top of the LeftControl.xaml.cs file using System.ComponentModel.Composition; 10.   Add the following attribute to the LeftControl class     [Export(typeof(LeftControl))]   This attribute tells MEF that the type LeftControl will be exported – i.e. made available for other applications to import and compose into the application. 11.   Add a new user control called RightControl to the ExternalSilverlightApplication project. 12.   Replace the LayoutRoot Grid with the following xaml:     <Grid x:Name="LayoutRoot" Background="Green" Margin="40"  >         <TextBlock Margin="40" Foreground="White" Text="Right Control" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Center" ></TextBlock>     </Grid> 13.   Add the following statement to the top of the RightControl.xaml.cs file using System.ComponentModel.Composition; 14.   Add the following attribute to the RightControl class     [Export(typeof(RightControl))] 15.   In your original Silverlight project add a reference to the ExternalSilverlightApplication project. 16.   Change the reference to the ExternalSilverlightApplication project to have it’s Copy Local value = false.  This will ensure that the referenced ExternalSilverlightApplication Silverlight application is not included in the original Silverlight application package when it it built.  The ExternalSilverlightApplication Silverlight application therefore has to be downloaded on demand by the original Silverlight application for it’s controls to be used. 1.     In your original Silverlight project add the following xaml to the LayoutRoot Grid in MainPage.xaml:         <Grid.RowDefinitions>             <RowDefinition Height="65*" />             <RowDefinition Height="235*" />         </Grid.RowDefinitions>         <Button Name="LoaderButton" Content="Download External Controls" Click="Button_Click"></Button>         <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" >             <Border Name="LeftContent" Background="Red" BorderBrush="Gray" CornerRadius="20"></Border>             <Border Name="RightContent" Background="Red" BorderBrush="Gray" CornerRadius="20"></Border>         </StackPanel>       The borders will hold the controls that will be downlaoded, imported and composed via MEF when the button is clicked. 2.     Add the following statement to the top of the MainPage.xaml.cs file using System.ComponentModel.Composition; 3.     Add the following properties to the MainPage class:         [Import(typeof(LeftControl))]         public LeftControl LeftUserControl { get; set; }         [Import(typeof(RightControl))]         public RightControl RightUserControl { get; set; }   This defines properties accepting LeftControl and RightControl types.  The attrributes are used to tell MEF the discovered type that should be applied to the property when composition occurs. 17.   Add the following event handler for the button click to the MainPage.xaml.cs file:         private void Button_Click(object sender, RoutedEventArgs e)         {                   DeploymentCatalog deploymentCatalog =     new DeploymentCatalog("ExternalSilverlightApplication.xap");                   CompositionHost.Initialize(deploymentCatalog);                   deploymentCatalog.DownloadCompleted += (s, i) =>                 {                     if (i.Error == null)                     {                         CompositionInitializer.SatisfyImports(this);                           LeftContent.Child = LeftUserControl;                         RightContent.Child = RightUserControl;                         LoaderButton.IsEnabled = false;                     }                 };                   deploymentCatalog.DownloadAsync();         } This is where the magic happens!  The deploymentCatalog object is pointed to the ExternalSilverlightApplication.xap file.  It is then associated with the CompositionHost initialization.  As the download will be asynchronous, an eventhandler is created for the DownloadCompleted event.  The deploymentCatalog object is then told to start the asynchronous download. The event handler that executes when the download is completed uses the CompositionInitializer.SatisfyImports() function to tell MEF to satisfy the Imports for the current class.  It is at this point that the LeftUserControl and RightUserControl properties are initialized with composed objects from the downloaded ExternalSilverlightApplication.xap package. 18.   Run the application click the Download External Controls button and see the controls defined in the ExternalSilverlightApplication application loaded into the original Silverlight application. Congratulations!  You have implemented download on demand capabilities for composite applications using the MEF DeploymentCatalog class.  You are now able to segment your applications into separate xap file for deployment.

    Read the article

  • Attaching a Command to the WP7 Application Bar.

    - by mbcrump
    One of the biggest problems that I’ve seen with people creating WP7 applications is how do you bind the application bar to a Relay Command. If your using MVVM then this is particular important. Let’s examine the code that one might add to start with.  <phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/icons/appbar.questionmark.rest.png" Text="About"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding DisplayAbout, Mode=OneWay}" /> </i:EventTrigger> </i:Interaction.Triggers> </shell:ApplicationBarIconButton> <shell:ApplicationBar.MenuItems> <shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"></shell:ApplicationBarMenuItem> <shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"></shell:ApplicationBarMenuItem> </shell:ApplicationBar.MenuItems> </shell:ApplicationBar> </phone:PhoneApplicationPage.ApplicationBar> Everything looks right. But we quickly notice that we have a squiggly line under our Interaction.Triggers. The problem is that the object is not a FrameworkObject. This same code would have worked perfect if this were a normal button. OK. Point has been proved. Let’s make the ApplicationBar support Commands. So, go ahead and create a new project using MVVM Light. If you want to check out the source and work along side this tutorial then click here.  7 Easy Steps to have binding on the Application Bar using MVVM Light (I might add that you don’t have to use MVVM Light to get this functionality, I just prefer it.) 1) Download MVVM Light if you don’t already have it and install the project templates. It is available at http://mvvmlight.codeplex.com/. 2) Click File-New Project and navigate to Silverlight for Windows Phone. Make sure you use the MVVM Light (WP7) Template. 3) Now that we have our project setup and ready to go let’s download a wrapper created by Nicolas Humann here, it is called Phone7.Fx. After you download it then extract it somewhere that you can find it. This wrapper will make our application bar/menu item bindable. 4) Right click References inside your WP7 project and add the .dll file to your project. 5) In your MainPage.xaml you will need to add the proper namespace to it. Don’t forget to build your project afterwards. xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview" 6) Now you can add the BindableAppBar to your MainPage.xaml with a few lines of code.  <Preview:BindableApplicationBar x:Name="AppBar" BarOpacity="1.0" > <Preview:BindableApplicationBarIconButton Command="{Binding DisplayAbout}" IconUri="/icons/appbar.questionmark.rest.png" Text="About" /> <Preview:BindableApplicationBar.MenuItems> <Preview:BindableApplicationBarMenuItem Text="Settings" Command="{Binding InputBox}" /> </Preview:BindableApplicationBar.MenuItems> </Preview:BindableApplicationBar> So your final MainPage.xaml will look similar to this: NOTE: The AppBar will be located inside of the Grid using this wrapper.   <!--LayoutRoot contains the root grid where all other page content is placed--> <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <!--TitlePanel contains the name of the application and page title--> <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12"> <TextBlock x:Name="ApplicationTitle" Text="{Binding ApplicationTitle}" Style="{StaticResource PhoneTextNormalStyle}" /> <TextBlock x:Name="PageTitle" Text="{Binding PageName}" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}" /> </StackPanel> <!--ContentPanel - place additional content here--> <Grid x:Name="ContentGrid" Grid.Row="1"> <TextBlock Text="{Binding Welcome}" Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="40" /> </Grid> <Preview:BindableApplicationBar x:Name="AppBar" BarOpacity="1.0" > <Preview:BindableApplicationBarIconButton Command="{Binding DisplayAbout}" IconUri="/icons/appbar.questionmark.rest.png" Text="About" /> <Preview:BindableApplicationBar.MenuItems> <Preview:BindableApplicationBarMenuItem Text="Settings" Command="{Binding InputBox}" /> </Preview:BindableApplicationBar.MenuItems> </Preview:BindableApplicationBar> </Grid> 7) Let’s go ahead and create the RelayCommands and write them up to a MessageBox by editing our MainViewModel.cs file. public class MainViewModel : ViewModelBase { public string ApplicationTitle { get { return "MVVM LIGHT"; } } public string PageName { get { return "My page:"; } } public string Welcome { get { return "Welcome to MVVM Light"; } } public RelayCommand DisplayAbout { get; private set; } public RelayCommand InputBox { get; private set; } /// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (IsInDesignMode) { // Code runs in Blend --> create design time data. } else { DisplayAbout = new RelayCommand(() => { MessageBox.Show("About box called!"); }); InputBox = new RelayCommand(() => { MessageBox.Show("settings button called"); }); } } If you run the project now you should get something similar to this (notice the AppBar at the bottom):  Now if you hit the question mark then you will get the following MessageBox: The MenuItem works as well so for Settings: As you can see, its pretty easy to add a Command to the ApplicationBar/MenuItem. If you want to look through the full source code then click here.   Subscribe to my feed

    Read the article

  • data validation on wpf passwordbox:type password, re-type password

    - by black sensei
    Hello Experts !! I've built a wpf windows application in with there is a registration form. Using IDataErrorInfo i could successfully bind the field to a class property and with the help of styles display meaningful information about the error to users.About the submit button i use the MultiDataTrigger with conditions (Based on a post here on stackoverflow).All went well. Now i need to do the same for the passwordbox and apparently it's not as straight forward.I found on wpftutorial an article and gave it a try but for some reason it wasn't working. i've tried another one from functionalfun. And in this Functionalfun case the properties(databind,databound) are not recognized as dependencyproperty even after i've changed their name as suggested somewhere in the comments plus i don't have an idea whether it will work for a windows application, since it's designed for web. to give you an idea here is some code on textboxes <Window.Resources> <data:General x:Key="recharge" /> <Style x:Key="validButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" > <Setter Property="IsEnabled" Value="False"/> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding ElementName=txtRecharge, Path=(Validation.HasError)}" Value="false" /> </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="True" /> </MultiDataTrigger> </Style.Triggers> </Style> <Style x:Key="txtboxerrors" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <DockPanel LastChildFill="True"> <TextBlock DockPanel.Dock="Bottom" FontSize="8" FontWeight="ExtraBold" Foreground="red" Padding="5 0 0 0" Text="{Binding ElementName=showerror, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"></TextBlock> <Border BorderBrush="Red" BorderThickness="2"> <AdornedElementPlaceholder Name="showerror" /> </Border> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </Window.Resources> <TextBox Margin="12,69,12,70" Name="txtRecharge" Style="{StaticResource txtboxerrors}"> <TextBox.Text> <Binding Path="Field" Source="{StaticResource recharge}" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <ExceptionValidationRule /> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox> <Button Height="23" Margin="98,0,0,12" Name="btnRecharge" VerticalAlignment="Bottom" Click="btnRecharge_Click" HorizontalAlignment="Left" Width="75" Style="{StaticResource validButton}">Recharge</Button> some C# : class General : IDataErrorInfo { private string _field; public string this[string columnName] { get { string result = null; if(columnName == "Field") { if(Util.NullOrEmtpyCheck(this._field)) { result = "Field cannot be Empty"; } } return result; } } public string Error { get { return null; } } public string Field { get { return _field; } set { _field = value; } } } So what are suggestion you guys have for me? I mean how would you go about this? how do you do this since the databinding first purpose here is not to load data onto the fields they are just (for now) for data validation. thanks for reading this.

    Read the article

  • WPF - How can I place a usercontrol over an AdornedElementPlaceholder?

    - by Kevin
    I'm trying to get the validation to not show through my custom modal dialog. I've tried setting the zindex of the dialog and and of the elements in this template. Any ideas? This is coming from a validation template: <ControlTemplate x:Key="ValidationTemplate"> <DockPanel> <TextBlock Foreground="Red" FontSize="20" Panel.ZIndex="-10">!</TextBlock> <Border Name="validationBorder" BorderBrush="Red" BorderThickness="2" Padding="1" CornerRadius="3" Panel.ZIndex="-10"> <Border.Resources> <Storyboard x:Key="_blink"> <ColorAnimationUsingKeyFrames AutoReverse="True" BeginTime="00:00:00" Storyboard.TargetName="validationBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" RepeatBehavior="Forever"> <SplineColorKeyFrame KeyTime="00:00:1" Value="#00FF0000"/> </ColorAnimationUsingKeyFrames> </Storyboard> </Border.Resources> <Border.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Loaded"> <BeginStoryboard Storyboard="{StaticResource _blink}" /> </EventTrigger> </Border.Triggers> <AdornedElementPlaceholder/> </Border> </DockPanel> </ControlTemplate> The dialog: <UserControl 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" x:Class="GunMiser.Controls.PendingChangesConfirmationDialog" Height="768" Width="1024" mc:Ignorable="d"> <Grid Background="White"> <Rectangle x:Name="MainRectangle" Margin="0,0,0,0" Style="{DynamicResource UserControlOverlayRectangleStyle}" Opacity="0.85"/> <Border Margin="288,250,278,288" Background="#FF868686" BorderBrush="Black" BorderThickness="1"> <Border.Effect> <DropShadowEffect Color="#FFB6B2B2"/> </Border.Effect> <TextBlock x:Name="textBlockMessage" Margin="7,29,7,97" TextWrapping="Wrap" d:LayoutOverrides="VerticalAlignment" TextAlignment="Center"/> </Border> <Button x:Name="OkButton" Click="OkButton_Click" Margin="313,0,0,328" VerticalAlignment="Bottom" Height="24" Content="Save Changes" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Left" Width="103"/> <Button Click="CancelButton_Click" Margin="453.294,0,456,328" VerticalAlignment="Bottom" Height="24" Content="Cancel Changes" Style="{DynamicResource GunMiserButtonStyle}"/> <Button Click="CancelActionButton_Click" Margin="0,0,304,328" VerticalAlignment="Bottom" Height="24" Content="Go Back" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Right" Width="114.706"/> </Grid> </UserControl> And the overall window is: <Window x:Class="GunMiser.Views.Shell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cal="http://www.codeplex.com/CompositeWPF" xmlns:controls="clr-namespace:GunMiser.Controls;assembly=GunMiser.Controls" Title="Gun Miser" Height="768" Width="1024"> <Canvas> <controls:PendingChangesConfirmationDialog x:Name="PendingChangesConfirmationDialog" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="1008" Height="730" Visibility="Collapsed" Panel.ZIndex="100" /> <ContentControl x:Name="FilterRegion" cal:RegionManager.RegionName="FilterRegion" Width="326" Height="656" Canvas.Top="32" VerticalAlignment="Top" HorizontalAlignment="Left" /> <ContentControl Name="WorkspaceRegion" cal:RegionManager.RegionName="WorkspaceRegion" Width="678" Height="726" Canvas.Left="330" VerticalAlignment="Top" HorizontalAlignment="Left"/> <Button Click="GunsButton_Click" Width="75" Height="25" Content="Guns" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/> <Button Click="OpticsButton_Click" Width="75" Height="25" Content="Optics" Canvas.Left="81" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/> <Button Click="SettingsButton_Click" Width="56" Height="28" Content="Settings" Canvas.Left="944" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Left" VerticalAlignment="Top"/> <Button Click="AccessoriesButton_Click" Width="75" Height="25" Content="Accessories" Canvas.Left="239" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/> <Button Click="AmmunitionButton_Click" Width="75" Height="25" Content="Ammunition" Canvas.Left="160" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/> </Canvas> </Window>

    Read the article

  • In WPF, how do I get a command in a Control Template to bind to a property in a parent?

    - by Keith
    I am relatively new to WPF and sometimes it makes my head explode. However, I do like the power behind it, especially when used with the MVVM model. I have a control template that contains a button. I use that control template inside of a custom control. I want to add a property on the custom control that will bind to the command property of the button inside the control template. Basically, it is a combo box with a button to the right of it to allow a user to pop up a search dialog. Since this control could appear on a usercontrol multiple times, I need to be able to potentially bind each control to a different command (Searh products, search customers, etc). However, I have been unable to figure out how to do this Here is some sample XAML <Style TargetType="{x:Type m:SelectionFieldControl}"> <Setter Property="LookupTemplate" Value="{StaticResource LookupTemplate}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type m:SelectionFieldControl}"> <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True" Focusable="False"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" MinWidth="0" SharedSizeGroup="{Binding LabelShareSizeGroupName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type m:BaseFieldControl}}}" /> <ColumnDefinition Width="1*" /> <ColumnDefinition Width="Auto" SharedSizeGroup="{Binding WidgetsShareSizeGroupName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type m:BaseFieldControl}}}" /> </Grid.ColumnDefinitions> <!-- Customized Value Part --> <ComboBox x:Name="PART_Value" Grid.Column="1" Margin="4,2,0,1" SelectedValue="{Binding Path=SelectionField.Value, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type m:SelectionFieldControl}}}" IsEnabled="{Binding Field.IsNotReadOnly, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type m:SelectionFieldControl}}}" Visibility="{Binding Field.IsInEditMode, Converter={StaticResource TrueToVisible}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type m:SelectionFieldControl}}}" FontFamily="{StaticResource FontFamily_Default}" FontSize="11px"> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling"/> </ItemsPanelTemplate> </ComboBox.ItemsPanel> </ComboBox> <StackPanel Grid.Column="2" Orientation="Horizontal" Name="PART_Extra" Focusable="False"> <ContentControl Name="PART_LookupContent" Template="{Binding LookupTemplate, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type m:SelectionFieldControl}}}" Focusable="False"/> </StackPanel> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> I thought I could get it to work by doing something like this <Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type SelectionFieldControl}}, Path=ShowSearchCommand}" Margin="2" /> but it does not work. Any help would be greatly appreciated.

    Read the article

  • Filtering in a HierarchicalDataTemplate via MarkupExtension?

    - by Dan Bryant
    I'm trying to create a MarkupExtension to allow filtering of items in an ItemsSource of a HierarchicalDataTemplate. In particular, I'd like to be able to supply a method name that will be executed on the DataContext in order to perform the filtering. The usage syntax I'm after looks like this: <HierarchicalDataTemplate DataType="{x:Type src:DeviceBindingViewModel}" ItemsSource="{Utilities:FilterCollection {Binding Definition.Entries}, MethodName=FilterEntries}"> <StackPanel Orientation="Horizontal"> <Image Source="{StaticResource BindingImage}" Width="24" Height="24" Margin="3"/> <TextBlock Text="{Binding DisplayName}" FontSize="12" VerticalAlignment="Center"/> </StackPanel> </HierarchicalDataTemplate> My code for the custom MarkupExtension looks like this: public sealed class FilterCollectionExtension : MarkupExtension { private readonly MultiBinding _binding; private Predicate<Object> _filterMethod; public string MethodName { get; set; } public FilterCollectionExtension(Binding binding) { _binding = new MultiBinding(); _binding.Bindings.Add(binding); //We package a reference to the DataContext with the binding so that the Converter has access to it var selfBinding = new Binding {RelativeSource = RelativeSource.Self}; _binding.Bindings.Add(selfBinding); _binding.Converter = new InternalConverter(this); } public FilterCollectionExtension(Binding binding, string methodName) : this(binding) { MethodName = methodName; } public override object ProvideValue(IServiceProvider serviceProvider) { return _binding; } private bool FilterInternal(Object dataContext, Object value) { //Filtering is only applicable if a DataContext is defined if (dataContext != null) { if (_filterMethod == null) { var type = dataContext.GetType(); var method = type.GetMethod(MethodName, new[] { typeof(Object) }); if (method == null || method.ReturnType != typeof(bool)) throw new InvalidOperationException("Could not locate a filter predicate named " + MethodName + " on the DataContext"); _filterMethod = (Predicate<Object>)Delegate.CreateDelegate(typeof(Predicate<Object>), dataContext, method); } else { if (_filterMethod.Target != dataContext) { _filterMethod = (Predicate<Object>) Delegate.CreateDelegate(typeof (Predicate<Object>), dataContext, _filterMethod.Method); } } if (_filterMethod != null) return _filterMethod(value); } //If no filtering resolved, just allow all elements return true; } private class InternalConverter : IMultiValueConverter { private readonly FilterCollectionExtension _owner; public InternalConverter(FilterCollectionExtension owner) { _owner = owner; } public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var enumerable = values[0]; var targetElement = (FrameworkElement)values[1]; var view = CollectionViewSource.GetDefaultView(enumerable); view.Filter = item => _owner.FilterInternal(targetElement.DataContext, item); return view; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException("Cannot convert back"); } } } I can see that the extension is instantiated and I can see it return the MultiBinding that is used by the Template. I also see the call to the InternalConverter.Convert method, which sees the expected parameters (I see the collection provided by the nested {Binding}) and is successfully able to retrieve the ICollectionView for the incoming collection. The only problem is that FilterInternal never gets called. The template is ultimately being used by a TreeView, if that's relevant. I haven't been able to figure out why the FilterInternal method is not being called and I was hoping somebody might be able to offer some insight.

    Read the article

  • How to get objects to react to touches in Cocos2D?

    - by Wayfarer
    Alright, so I'm starting to learn more about Coco2D, but I'm kinda frusterated. A lot of the tutorials I have found are for outdated versions of the code, so when I look through and see how they do certain things, I can't translate it into my own program, because a lot has changed. With that being said, I am working in the latest version of Coco2d, version 0.99. What I want to do is create a sprite on the screen (Done) and then when I touch that sprite, I can have "something" happen. For now, let's just make an alert go off. Now, I got this code working with the help of a friend. Here is the header file: // When you import this file, you import all the cocos2d classes #import "cocos2d.h" // HelloWorld Layer @interface HelloWorld : CCLayer { CGRect spRect; } // returns a Scene that contains the HelloWorld as the only child +(id) scene; @end And here is the implementation file: // // cocos2d Hello World example // http://www.cocos2d-iphone.org // // Import the interfaces #import "HelloWorldScene.h" #import "CustomCCNode.h" // HelloWorld implementation @implementation HelloWorld +(id) scene { // 'scene' is an autorelease object. CCScene *scene = [CCScene node]; // 'layer' is an autorelease object. HelloWorld *layer = [HelloWorld node]; // add layer as a child to scene [scene addChild: layer]; // return the scene return scene; } // on "init" you need to initialize your instance -(id) init { // always call "super" init // Apple recommends to re-assign "self" with the "super" return value if( (self=[super init] )) { // create and initialize a Label CCLabel* label = [CCLabel labelWithString:@"Hello World" fontName:@"Times New Roman" fontSize:64]; // ask director the the window size CGSize size = [[CCDirector sharedDirector] winSize]; // position the label on the center of the screen label.position = ccp( size.width /2 , size.height/2 ); // add the label as a child to this Layer [self addChild: label]; CCSprite *sp = [CCSprite spriteWithFile:@"test2.png"]; sp.position = ccp(300,200); [self addChild:sp]; float w = [sp contentSize].width; float h = [sp contentSize].height; CGPoint aPoint = CGPointMake([sp position].x - (w/2), [sp position].y - (h/2)); spRect = CGRectMake(aPoint.x, aPoint.y, w, h); CCSprite *sprite2 = [CCSprite spriteWithFile:@"test3.png"]; sprite2.position = ccp(100,100); [self addChild:sprite2]; //[self registerWithTouchDispatcher]; self.isTouchEnabled = YES; } return self; } // on "dealloc" you need to release all your retained objects - (void) dealloc { // in case you have something to dealloc, do it in this method // in this particular example nothing needs to be released. // cocos2d will automatically release all the children (Label) // don't forget to call "super dealloc" [super dealloc]; } - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //CGPoint location = [[CCDirector sharedDirector] convertCoordinate:[touch locationInView:touch.view]]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; if (CGRectContainsPoint(spRect, location)) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Win" message:@"testing" delegate:nil cancelButtonTitle:@"okay" otherButtonTitles:nil]; [alert show]; [alert release]; NSLog(@"TOUCHES"); } NSLog(@"Touch got"); } However, this only works for 1 object, the sprite which I create the CGRect for. I can't do it for 2 sprites, which I was testing. So my question is this: How can I have all sprites on the screen react to the same event when touched? For my program, the same event needs to be run for all objects of the same type, so that should make it a tad easier. I tried making a subclass of CCNode and over write the method, but that just didn't work at all... so I'm doing something wrong. Help would be appreciated!

    Read the article

  • Applet Loading Error - Jasper Report

    - by Mihir
    I encountered very silly error , but any way i can not figure out solution.i am loading java applet which encompass a simple jasper viewer in it. when the applet is loaded it throws following exception. SEVERE: Servlet.service() for servlet JasperReportServlet threw exception java.lang.ClassNotFoundException: org.apache.commons.collections.ReferenceMap at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.<init>(DefaultExtensionsRegistry.java:96) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at java.lang.Class.newInstance0(Class.java:355) at java.lang.Class.newInstance(Class.java:308) at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:59) at net.sf.jasperreports.extensions.ExtensionsEnvironment.createDefaultRegistry(ExtensionsEnvironment.java:80) at net.sf.jasperreports.extensions.ExtensionsEnvironment.<clinit>(ExtensionsEnvironment.java:68) at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:76) at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:182) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:78) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624) at com.dbhl.app.report.generator.JobUpdateGenerator.getJasperPrintObject(JobUpdateGenerator.java:279) at com.dbhl.app.report.JasperReportServlet.processJobUpdate(JasperReportServlet.java:153) at com.dbhl.app.report.JasperReportServlet.getJasperPrintObjectByLedgerType(JasperReportServlet.java:79) at com.dbhl.app.report.JasperReportServlet.service(JasperReportServlet.java:50) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) below is my applet configuration, i am loading applet using standard java deployment toolkit. <script type="text/javascript" src="<%=basePath%>js/deployJava.js"> </script> <script> var user = '<%=request.getParameter("user")%>'; var attributes = { code : 'applet.EmbeddedViewerApplet.class', archive : '<%=basePath%>resources/appletviewer.jar,<%=basePath%>resources/jasperreports-applet-4.0.0.jar,<%=basePath%>resources/jasperreports-4.0.0.jar,<%=basePath%>resources/commons-collections-3.2.1.jar,<%=basePath%>resources/commons-logging-1.0.4.jar,<%=basePath%>resources/commons-beanutils-1.8.0.jar,<%=basePath%>resources/commons-digester-1.7.jar,<%=basePath%>resources/commons-javaflow-20060411.jar,<%=basePath%>resources/org-netbeans-core.jar', width : "100%", height : 600 }; var parameters = { fontSize : 16, REPORT_URL : '<%=basePath%>servlet/JasperReportServlet?startDate=<%=request.getParameter("startDate")%>&endDate=<%=request.getParameter("endDate")%>&user=' + user + '&reportType=<%=request.getParameter("reportType")%>' }; var version = '1.4'; deployJava.runApplet(attributes, parameters, version); </script> every jar i referred in the applet attributes exist the resource folder of my webroot, which are appletviewer.jar commons-beanutils-1.8.0.jar commons-collections-3.2.1.jar commons-digester-1.7.jar commons-javaflow-20060411.jar commons-logging-1.0.4.jar jasperreports-4.0.0.jar jasperreports-applet-4.0.0.jar org-netbeans-core.jar all the jars are signed today, so no validity expires. i have double check all the things. but it always shows the above error. in iReport i can view the report and it is compiled to jasper object with no error. the java console from control panel http://pastebin.com/Xt6303tT My question is why the classNotFound Exception happens ? i check in the temp cache that the collections file is downloaded succesfully and in the above console log it shows that the jars are successfully downloaded to the host computer. Thank You Mihir Parekh

    Read the article

  • Multibinding File-Paths into a Button ControlTemplate

    - by Bill
    I am trying to develop an application that uses a number of images that are stored in a seperate remote file location. The file-paths to the UI elements are stored within the Application Settings. Although I understand how to access the images from Applications Settings using a MultiBinding and a value converter, I'm not sure how to integrate the Multibinding into the ImageButton ControlTemplate below. Can anyone steer me in the right direction? <Image.Source> <MultiBinding Converter="{StaticResource MyConverter}"> <Binding Source="{StaticResource Properties.Settings}" Path="Default.pathToInterfaceImages" /> <Binding Source="ScreenSaver.png"></Binding> </MultiBinding> </Image.Source> <Button Click="btn_ScreenSaver_Click" Style="{DynamicResource ThreeImageButton}" local:ThreeImageButton.Image="C:\Skins\ScreenSaver_UP.png" local:ThreeImageButton.MouseOverImage="C:\Skins\ScreenSaver_OVER.png" local:ThreeImageButton.PressedImage="C:\Skins\ScreenSaver_DOWN.png"/> <Style x:Key="ThreeImageButton" TargetType="{x:Type Button}"> <Setter Property="FontSize" Value="10"/> <Setter Property="Height" Value="34"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <StackPanel Orientation="Horizontal" > <Image Name="PART_Image" Source= "{Binding Path=(local:ThreeImageButton.Image), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" /> </StackPanel> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Source" Value="{Binding Path=(local:ThreeImageButton.MouseOverImage), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" TargetName="PART_Image"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Source" Value="{Binding Path=(local:ThreeImageButton.PressedImage), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" TargetName="PART_Image"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Source" Value="{Binding Path=(local:ThreeImageButton.Image), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" TargetName="PART_Image"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> public class ThreeImageButton : DependencyObject { // Add three new Dependency Properties to the Button Class to hold the // path to each of the images that are bound to the control, displayed // during normal, mouse-over and pressed states. public static readonly DependencyProperty ImageProperty; public static readonly DependencyProperty MouseOverImageProperty; public static readonly DependencyProperty PressedImageProperty; public static ImageSource GetImage(DependencyObject obj) { return (ImageSource)obj.GetValue(ImageProperty); } public static ImageSource GetMouseOverImage(DependencyObject obj) { return (ImageSource)obj.GetValue(MouseOverImageProperty); } public static ImageSource GetPressedImage(DependencyObject obj) { return (ImageSource)obj.GetValue(PressedImageProperty); } public static void SetImage(DependencyObject obj, ImageSource value) { obj.SetValue(ImageProperty, value); } public static void SetMouseOverImage(DependencyObject obj, ImageSource value) { obj.SetValue(MouseOverImageProperty, value); } public static void SetPressedImage(DependencyObject obj, ImageSource value) { obj.SetValue(PressedImageProperty, value); } // Register each property with the control. static ThreeImageButton() { var metadata = new FrameworkPropertyMetadata((ImageSource)null); ImageProperty = DependencyProperty.RegisterAttached("Image", typeof(ImageSource), typeof(ThreeImageButton), metadata); var metadata1 = new FrameworkPropertyMetadata((ImageSource)null); MouseOverImageProperty = DependencyProperty.RegisterAttached("MouseOverImage", typeof(ImageSource), typeof(ThreeImageButton), metadata1); var metadata2 = new FrameworkPropertyMetadata((ImageSource)null); PressedImageProperty = DependencyProperty.RegisterAttached("PressedImage", typeof(ImageSource), typeof(ThreeImageButton), metadata2); } }

    Read the article

  • WPF DataTemplateKey can not find ListBox key

    - by Ryan
    I am fairly new to WPF and am having trouble getting the DataTemplateKey to find my ListBox. <Window.Resources> <ControlTemplate x:Key="FocusTemplate" > <Rectangle Fill="Azure" Width="290" Height="55" /> </ControlTemplate> <Style x:Key="FocusStyle" TargetType="{x:Type Control}"> <Setter Property="Template" Value="{StaticResource FocusTemplate}"/> </Style> <Style TargetType="ListBoxItem"> <EventSetter Event="GotFocus" Handler="ListItem_GotFocus"></EventSetter> </Style> <DataTemplate DataType="{x:Type TextBlock}"> </DataTemplate> <DataTemplate x:Key="CustomListData" DataType="{x:Type ListBox}"> <Border BorderBrush="Black" BorderThickness="1" Margin="-2,0,0,-1"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="1"/> <SkewTransform AngleX="0" AngleY="0"/> <RotateTransform Angle="0"/> <TranslateTransform X="0" Y="0"/> </TransformGroup> </Grid.RenderTransform> <!--<ScrollViewer x:Name="PART_ContentHost" />--> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="18" FocusVisualStyle="{StaticResource FocusStyle}" Name="editingBox" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" > <TextBox.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5"/> <SkewTransform CenterX="0.5" CenterY="0.5"/> <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF2D4984"/> <GradientStop Color="#FF182D56" Offset="0.042"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </Border> </DataTemplate> <Style TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate" Value="{StaticResource CustomListData }" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> </Style> </Window.Resources> <Window.DataContext> <ObjectDataProvider ObjectType="{x:Type local:ImageLoader}" MethodName="LoadImages" /> </Window.DataContext> <ListBox ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79"> <ListBox.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</SolidColorBrush> </ListBox.Resources> </ListBox> The following code will find a TextBlock var key = new System.Windows.DataTemplateKey(typeof(TextBlock)); var r = (DataTemplate)this.FindResource(key); However, when I change the type to ListBox, the key can not be found. What have I missed? Thanks Ryan

    Read the article

< Previous Page | 8 9 10 11 12 13  | Next Page >