Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

Grid view and xml in c#(not asp.net application)

$
0
0

Please note that its not asp.net application its windows form application. SO please do not direct this post to asp.net forums without reading through this.

I have  a xml file as below

-<Log_details>
  -<Log><LogNo>82910</LogNo><CDI>75880</CDI><Time>2013-03-01.11:31:25.524</Time><PID>0d2264</PID><Source>CAP</Source><Destination>AM</Destination>         <MessageId>9A22</MessageId>
     -<Payload><API_Name>MasEndAllCallsByCDIClientID</API_Name><wMasClientId>(0X000D)</wMasClientId><RawData>0000.0500.0000.0000.0000.0000.0000</RawData></Log></Log_details>
i am displaying this on dataset but i am not getting the data of payload.

Please do some one help me on this.


Girish


Girish


Priting in WPF fails to use the user specified printer tray

$
0
0

Hi,

The following code is being used to print some documents. The problem we are having is that no matter what tray we use it always appears to use the default tray. Any help would be greatly appreciated. We were thinking everything hsould be in the UserPrintTicket:

        /// <summary>Print pages.</summary>
        /// <param name="pageViewModels">The page view models.</param>
        private void PrintPages(IEnumerable<IPageViewModel> pageViewModels)
        {
            var printDialog = new PrintDialog();
            bool? print = printDialog.ShowDialog();
            if (print == true)
            {
                var dw = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
                var mediaSize = printDialog.PrintQueue.UserPrintTicket.PageMediaSize;
                printDialog.PrintQueue.CurrentJobSettings.Description = "PDAX Document Pages";
                var area = printDialog.PrintQueue.GetPrintCapabilities().PageImageableArea;
                var img = new Image();
                img.Margin = new Thickness(area.OriginWidth, area.OriginHeight, area.OriginWidth, area.OriginHeight);
                var outputSize = new Size(mediaSize.Width.Value, mediaSize.Height.Value);
                var c = dw.CreateVisualsCollator();
                c.BeginBatchWrite();
                foreach (var page in pageViewModels)
                {
                    img.Source = ConvertByteArrayToBitmap(page.Image);
                    img.Measure(outputSize);
                    img.Arrange(new Rect(outputSize));
                    img.UpdateLayout();
                    c.Write(img);
                }

                c.EndBatchWrite();
            }
        }

Check If Is Child In Logical Or Visual Tree

$
0
0

Hi,

how can I check if a child is in LogicalTree or in VisualTree?

Is there something like UIElement.IsInVisualTree or UIElement.IsInLogicalTree?

So the question is how do I find out no matter when at runtime if a child (i could pick any random child) is in LogicalTree or in VisualTree?

WPF USERINTERFACE

$
0
0
how to create a windows 8 tile look in an WPF application?

ribbon linbreak ?

$
0
0

hi!

I have a ribbon with a alot of Buttons but there are to many Buttons in a line...

I Need all the Buttons in the line!

Here is a Picture with my Problem:

Now I Need an idea that i can see all Buttons (16,27,...)

Is there a linebreak in the ribbon control?

Best Regards

Bernd

How to remember the size and location of a UserControl, instead of a Window.

$
0
0

Hello All,

I have a UserControl object that I instantiate and assign to a Window at runtime. I know how to remember the size and location for Window objects, as per this link:

http://www.thomaslevesque.com/2008/11/18/wpf-binding-to-application-settings-using-a-markup-extension/

Problem however is, that the user control only has Width and Height properties and not Top and Left such as a UserControl. 

How do I thus remember the location and size of a UserControl, so that the next time the user opens the app, it will be the same size and in the same location as when he closed?

Thanks.

Harriet

problem typing in wpf

$
0
0

hello all,i have a problem in wpf and that is notworking type in wpf ,

when press any key in keyboard for type to translate while not typing in textbox but spacebar key work corrently.

please help me.

FlowDocument Large Table Performance issues

$
0
0

Hello,

I've created a Flowdocument, consisting of one big table with ~20 cells and ~1600 rows resulting in performance issues.

First problem is, that rendering takes very long, im using FlowDocumentReader for this. When setting the created flowdocument as source of the reader i can see the number of pages increasing and when then switching to the scrollview the application freezes, takes much memory and finally crashes.

Is there any chance to improve the rendering performance?

Second problem is, when i then set the source of the flowdocumentreader to null again, the application freezes for ~1 minute with high cpu usage again.

Is there a better way of cleaning the document reader than setting the Document to null?

Thanks


Click event for added RibbonButton in quick access toolbar

$
0
0

Hi!

I'm using the new RibbonWindow from Microsoft. When I add a ribbon button to the quick access toolbar at runtime (via right click => add to quick access toolbar) and I click on the button in the quick access toolbar, the associated click event is not fired. It seems, the toolbar makes a copy of the original button, but does not copy the click event handler.

How do I detect a click on the newly added button?

Thanks!

Jus

 

 

Representing a number in a textbox

$
0
0

Good day,

please i want when i type a number in my GUI textbox to be represented  in a masked way like this eg. 500,000 instead of 500000 how do i do this thanks. i am using wpf


kels

Why the terrible change to the forums? Takes 5 mins just to filter to get where it took just a link?

$
0
0

I can't believe how terrible this change to the forum is!  I guess MS does not want these forums to continue as it now takes 5 mins just to put in all the filter information and that information is not even persisted!

Make it better!!!!!!!!!!!!!!!!!!!!


Lloyd Sheen

Detecting when a DataGridComboBoxColumn is selected

$
0
0

Hi

One of a ComboBox’s most commonly used and essential Events is SelectionChanged. It is raised when a selection is made in the ComboBox, which is the only purpose of a ComboBox (ie: making a Selection.)

A DataGridComboBoxColumn is also used only for 1 purpose - to make a selection. The only difference is that this column is hosted in a DataGrid. It should be possible to detect when a selection is made in a DataGridComboBoxColumn. However, it doesn’t provide a SelectionChanged event.

Is there a workaround to detect when a selection is made in a DataGridComboBoxColumn ?

Thanks.

Steven

Is it possible to bind a notification property to another non-UI property?

$
0
0

Is it possible to use the WPF binding mechanism in such a fashion so as to bind a notification property so that a non-UI object will be notified when the property changes? If so, how?


Richard Lewis Haggard

DataGridRow Background Color is not responding to DatagridComboBoxColumn Value

$
0
0

Hi friends,

The following code expect the DataGridRow background to be changed based on the value of DataGridComboBoxColumn Serviceability. but it is not happening for ComboBox Columns but same is tested with text box columns and same is happening

<DataGrid.Resources><Style TargetType="DataGridRow"><Style.Triggers><DataTrigger Binding="{Binding SERVICEABILTY}" Value="Serviceable"><Setter Property="Background" Value="Green" /></DataTrigger><DataTrigger Binding="{Binding SERVICEABILTY}" Value="NotServiceable"><Setter Property="Background" Value="Red" /></DataTrigger></Style.Triggers></Style></DataGrid.Resources><DataGridComboBoxColumn SelectedValueBinding="{Binding SERVICEABILITY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="SERVICEABILTY" DisplayMemberPath="SERVICEABILTY" Header="Serviceabilty" ><DataGridComboBoxColumn.ElementStyle><Style TargetType="ComboBox"><Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}, Path=combodisplayMC_CARD}" /><Setter Property="ItemTemplate"><Setter.Value><DataTemplate><TextBlock Foreground="Blue" Text="{Binding Path=SERVICEABILTY}"/></DataTemplate></Setter.Value></Setter></Style></DataGridComboBoxColumn.ElementStyle><DataGridComboBoxColumn.EditingElementStyle><Style TargetType="ComboBox"><Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}, Path=combodisplayMC_CARD}" /><Setter Property="ItemTemplate"><Setter.Value><DataTemplate><TextBlock Foreground="DarkMagenta" Text="{Binding Path=SERVICEABILTY}"/></DataTemplate></Setter.Value></Setter></Style></DataGridComboBoxColumn.EditingElementStyle></DataGridComboBoxColumn>



itismeiqbal

Add table to repeating pages flowdocument

$
0
0

Hello,

I am trying to add a table to start on every page before flowdocument starts to print or as a header. I have put the code of the table below.

Please help. All I want to do is to put this table when a page begins on each page. Please help with a Paginator which includes this table as a header please or an example.

Thank you in advance.

 Table table2 = new Table();
                table2.FontFamily = new System.Windows.Media.FontFamily("Arial");
                table2.CellSpacing = 0;
                // table1.Padding = ;
                table2.BorderBrush = System.Windows.Media.Brushes.LightGray;
                table2.BorderThickness = new Thickness(0, 0.5, 0, 0.5);
                int numberOfColumnvs = 9;
                for (int x = 0; x < numberOfColumnvs; x++)
                {
                    table2.Columns.Add(new TableColumn());
                    table2.Columns.Add(new TableColumn() { Width = GridLength.Auto });

                }
                // Create and add an empty TableRowGroup to hold the table's Rows.
                table2.RowGroups.Add(new TableRowGroup());

                // Add the first (title) row.
                //table1.RowGroups[0].Rows.Add(new TableRow());

                // Alias the current working row for easy reference.
                table2.RowGroups[0].Rows.Add(new TableRow());
                TableRow currentRow2 = table2.RowGroups[0].Rows[0];

                int t2df = (from b in conn.tblReQResults
                            where b.ResultID == GlobalVariables.ResultID && b.Result != "" && b.tblTestPram.tblSubTest.tblPanel.tblCategory.CatID == ynb.CatID
                            select b).Count();
                if (t2df != 0)
                {
                    table2.RowGroups[0].Rows.Add(new TableRow());
                    currentRow2 = table2.RowGroups[0].Rows[0];

                    currentRow2.Cells.Add(new TableCell(new Paragraph(new Run(ynb.Category))));
                    currentRow2.Cells[0].TextAlignment = TextAlignment.Center;
                    currentRow2.Cells[0].FontSize = 12;
                    currentRow2.Cells[0].FontWeight = System.Windows.FontWeights.Bold;
                    currentRow2.Cells[0].BorderThickness = new Thickness(0, 0, 0, 0.5);
                    currentRow2.Cells[0].BorderBrush = System.Windows.Media.Brushes.LightGray;
                    currentRow2.Cells[0].ColumnSpan = 9;
                    conn = new AtaLIMSDataContext();
                    section.Blocks.Add(table2);

}


ColorAnimation, StoryBoard and DataTrigger: Starts but doesn't stop

$
0
0
Hi

In a control template I have a rectangle whose style has a DataTrigger that listens to some boolean view model prop, which is most of the time set to "false".
When it turns to "true" a StoryBoard starts with a ColorAnimation that oszillates from one FIll-color to another
and back. This works fine and is all XAML.
However when the view model property turns back to "false" the storyboard and its color animation do not stop
but keeps on oscillating.

I'll show you my code:

<!-- StoryBoard in DataTrigger to change Fillcolor when "IsRotating" turns to true  --><Style x:Key="IsRotatingOuterFillStyle"
           TargetType="Shape"><Setter Property="Shape.Fill"
                Value="{StaticResource ResourceKey=ThumbsInvertedBrush}" /><Style.Triggers><DataTrigger Binding="{Binding Path=IsRotating}"
                         Value="True"><DataTrigger.EnterActions><BeginStoryboard><Storyboard><ColorAnimation Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"
                                            To="{StaticResource ResourceKey=ThumbsColor}"
                                            Duration="0:0:1"
                                            RepeatBehavior="Forever"
                                            AutoReverse="True" /></Storyboard></BeginStoryboard></DataTrigger.EnterActions></DataTrigger></Style.Triggers></Style>
<!-- custom control template that consume sthe style with the DataTrigger and the SotryBoard and that doesn't stop when "IsRotating" turns to false back again --><thumbs:RotationPointThumb.Template><ControlTemplate><Grid><Rectangle Height="{Binding ElementName=ZoomContextRotationPoint,Path=ZoomedSize2}"
                               VerticalAlignment="Center"Style="{StaticResource ResourceKey=IsRotatingOuterFillStyle}"
                               Margin="{Binding ElementName=ZoomContextRotationPoint,Path=ZoomedThickness1}" />
...

Of course the question is:
How to I convince the StoryBoard to stop when the DataTrigger turns to false again?
If possible without code-behind, pure XAML?

I already debugged the code and can rule out that the DataTrigger doesn't fire properly.
If I don't use a StoryBoard but just change the fill with a setter it works out fine.
It's the storyboard/coloranimation that ignores the reset.
Is there some special code that I need to STOP the storyboard?

Thanks,
Chris

Set DataGridRow color during run time from a PopUpBox

$
0
0

Hi friends,

 I want to set the color of a DataGridRow as follows. while right clicking a pop up box should come with all(some) available colors and clicking on some  color the corresponding row get the clicked color. how I can implement this.

Thanks in advance 

Iqbal


itismeiqbal

Login Form User Access Management WPF C#

$
0
0

Hi all

I have MainForm includes few menus and each menus have submenus say it login, logout, change password, User maintenance, Group maintenance etc.

when i run my program, all of submenus is inactive except login submenus to show a login form.

after success login, all of submenus is Active and enable to click.

I want to now how enable that inactive submenus after login is success?? and can i manage spesific of user to allow accessing that submenus?

example userA only access "User Maintenance" submenus and "Change Password"

and how to change password current type of users login?? 

sorry for my bad english i hope all of you understand what i ask :)

thx b4

How to close the Popup when user clicks anywhere outside the Popup and associated control?

$
0
0

I have created a style where I have changed the expanded portion of Expander to a Popup. A section of the style is given below.

<Style
  TargetType="{x:Type Expander}" x:Key="PopupExpanderStyle">
  
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type Expander}">

     <StackPanel Orientation="Vertical">

      <Border BorderBrush="{TemplateBinding BorderBrush}"
        
        SnapsToDevicePixels="true">
       <DockPanel LastChildFill="True">
        <ToggleButton x:Name="HeaderSite"
          DockPanel.Dock="Top"
          Margin="1"
          MinWidth="0"
          MinHeight="0"         
       </DockPanel>
      </Border>
      <!--ContentPresenter is removed from the upper border and added a new boder for it with Popup around it-->
      <Popup x:Name="PART_Popup"
       AllowsTransparency="true"
       Placement="Bottom"
       IsOpen="True">
       <Border x:Name="ExpandBorder" BorderBrush="{DynamicResource BlueBorder}" Margin="2,0,0,0"
        BorderThickness="{TemplateBinding BorderThickness}">
        <ContentPresenter x:Name="ExpandSite"         
             Visibility="Collapsed"
             Focusable="false"
             HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
             VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
             Margin="{TemplateBinding Padding}"/>
       </Border>
      </Popup>
     </StackPanel>

     <ControlTemplate.Triggers>
      <Trigger Property="IsExpanded"
        Value="true">
       <Setter Property="Visibility"
        Value="Visible"
        TargetName="ExpandSite"/>
      </Trigger>      

      <Trigger Property="IsEnabled" Value="false">
       <Setter Property="Foreground"
         Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

My Problem is when user expands the expander and then minmizes the window or goes to some other window, the Popup(Expanded portion of expander) remains visible at there place. I want to close it.....same way as ComboBox behaves.

In actual ComboBox the IsOpen is attached as given below

IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"

I don't know what to do in my case.

System.Windows.Baml2006.TypeConverterMarkupExtension threw an exception

$
0
0

This error has started to be thrown on one of our development machines. The following code is the cause

<Style.Triggers><Trigger Property="Validation.HasError" Value="True"><Setter Property="ToolTip"><Setter.Value><Binding Path="(Validation.Errors)[0].ErrorContent" RelativeSource="{x:Static RelativeSource.Self}" /></Setter.Value></Setter></Trigger></Style.Triggers>

 This XAML is in an ElementHost control on a Windows Form in VS2010. The code has previously worked OK and still appears to work on other machines. The solution contains multiple projects and I have deleted and reloaded the project from source code.

When the code is commented out the form loads OK (albeit without the tooltip functionality). When the code is uncommented this error returns

System.Windows.Markup.XamlParseException occurred
 Message='Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '66' and line position '42'.
 Source=PresentationFramework
 LineNumber=66
 LinePosition=42
I have seen a few posts and related topics on similar errors without seeing any definite resolution. Has anyone encountered something like this and been able to fix it? 

Viewing all 18858 articles
Browse latest View live