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

resource dictionary in a dll

$
0
0

hi
i'm trying to organize a resource dictionary

The project is a library that produce a dll
The resource are located in different folders like:
- resdir\brushes
- resdir\style
...
...

1. How can i merge it in a single resource accessible inside the library and from the application that will use it?

2. I'm not able to use it from the code behind, I tried with FindResource but it return null,
   Is it a good idea try to do this ?  ResourceDictionary res = Application.LoadComponent(new Uri(.........

Thank you


Get rid of binding error when applying a binding in a style

$
0
0

I am trying to create a style that adds a TranslateTransform to an Ellipse. I want to bind that RenderTransform's X property to the Ellipse's Width property. If I do that the binding works, but I get this weird error in the Output window in Visual Studio:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Shapes.Ellipse', AncestorLevel='1''. BindingExpression:Path=Width; DataItem=null; target element is 'TranslateTransform' (HashCode=59715965); target property is 'X' (type 'Double')

How do I fix this error? 

Here is the code I am using:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="300" Width="300"><Window.Resources><Style TargetType="Ellipse"><Setter Property="RenderTransform"><Setter.Value><TranslateTransform><TranslateTransform.X><Binding
                                    RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type Ellipse}}"
                                    Path="Width"/></TranslateTransform.X></TranslateTransform></Setter.Value></Setter></Style></Window.Resources><Canvas><Ellipse Width="100" Height="100" Fill="Red" /></Canvas></Window>

I want to say again, the binding works, I only want to get rid of the error in the output window.

Incorrect taskbar thumbnail when displaying video using hwnd.

$
0
0

I am building this C# WPF application, that uses libVLC to display videos. To display the video I use the 'libvlc_media_player_set_hwnd' function going through a long to describe way (My project is based on a modifity version of https://github.com/ZeBobo5/Vlc.DotNet, but it seems to be present in different library's for WPF). But after all it comes down to one problem the window is painted incorrect in the taskbar thumbnail.

Its a border less window, but there is noting wrong with my code, this problem only occurs when I am playing a video. And its only present in the taskbar thumbnail, but not Aero Snap or other DWM generated thumbnails as far as I know. 

There are empty pieces and missing pieces present in the thumbnail.


WPF Datagrid Cell Click

$
0
0

On this same datagrid or any datagrid, how do fire an event to the viewmodel

to determine what Cell and what column is click. Basically is the colorpath column

or anything cell in the colorpath column, I want to disable the EditColorButton

anytime a value is click in the colorpath column. How would I do that ?






Review the grid in the message  thread below

when window is maximize it’s displayed strangely—there’s a black background (see screenshot below); Maybe it is because of a max width?

$
0
0

Hi All,

when window is maximize it’s displayed strangely—there’s a black background (see screenshot below); Maybe it is because of a max width?

Let me explain why, I am using Elysium Framework. I am unsure if this is the right forum to post.This is because the monitor has high resolution. How to set AllowsTransparency="True"Without setting the Windows Style to None.

Thanks,

Weera


C# / WPF Scope Problems

$
0
0

Based on web searches, I am having problems in my project with scope that many seem to have problems understanding.

I am working on an C# / WPF application where I would like to put much of my code in supporting classes. This would include parameters/variable, methods, etc. I am able to do this, but only by passing arguments for variables, class instances, etc. I would like to define a few global variable and not have to repetitively pass these globally used arguments.

I have extensively reviewed MSDN, web, etc info on scope, but can not find info that provides guidance needed . I am sure it must be possible, but how? I obviously am not understanding what I read on Namespace; Class field, property, method, etc. scope.

Below is c# / WPF XAML code that illustrates what I hope to do.

Thank you.

<Window x:Class="Scope_Experiment.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
    </Grid>
</Window>

namespace Scope_Experiment
{
     /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public Window mainwin;
        public Class1 class1;
        public MainWindow()
        {
            InitializeComponent();
            mainwin = this;
            class1 = new Class1();
        }
    }
}

namespace Scope_Experiment
{
    class Class1
    {
        public String par1;
        public Double par2;

        public void method1()
        { /* Method Code */ }
    }
}


namespace Scope_Experiment
{
    class Class2
    {
        String C2par1 = class1.par1;
    }
}


Jim Gunn

Application won't run

$
0
0

I have written an application in WPF (VB). I use one machine at work, and one machine at home. When I compile it and run it at home, I get an error when I try to run it. The break point is in "Application.g.vb" in routine "Main" at the line "Run App". The error message is "An unhandled exception of type 'System.NotSupportedException' occurred in PresentationCore.dll".

The program compiled and ran at work (except that the hlsl shader effect (Shader model 3.0) is not supported on that machine. The shader model is supported at home (and even shows in design mode). It compiles OK at home but won't run the app.

I'm writing the app for my home computer. When I'm at work I use Real VNC to access my home computer and copy the files back and forth. I have VS 2013 on both computers. The one at work is 64 bit. The one at home is 32 bit.

WPF: How to froze the first column in the system.windows.documents.table?

$
0
0

Our WPF application includes report.

We use the DocumentViewer to host the FlowDocument to present a report.

Inside FlowDocument, there is a system.windows.documents.table.

The table includes 96 columns. so the table exceeds the one page width and Horizontal Scrollbar is displayed.

One of the requirement is on horizontal scroll the first column should be freezed and remaining columns should move.

Is there a easy way to achieve that? Thx!


JaneC



Show reports in WPF

$
0
0

Hi,

I have a transaction table to store all the transaction happened on a single day. as per my requirement I wrote the query like this

select CurrencyCode,TransactionCode,TransactionAmount,COUNT(TransactionCode) as [No. Of Trans] from

TransactionDetails where TransactionCode in('BNT','BCN','BTC','STC','SCN','SNT') group by TransactionCode,

CurrencyCode,TransactionAmount order by CurrencyCode

I got the result like this

My I want to show this result like this

                            ARS

  BNT         0            0

  BCN        0            0

  SCN        1            12

  BTC        0             0

  STC        0             0

  SNT        0             0

                            VND

  BNT         3           10001400

  BCN        0            0

  SCN        0            0

  BTC        0             0

  STC        0             0

  SNT        0             0

                            EUR

  BNT         2           290

  BCN        1           6.6

  SCN        0            0

  BTC        0             0

  STC        0             0

  SNT        0             0

 And so on ......

I have no Issue if it can be like this

                                                             EUR

Modes                BNT         BCN            SCN              BTC               STC            SNT

No. of Trans.       2              1                0                  0                    0                0

Amount               290          6.6              0                  0                    0                0

Please help me how can I achieve like this .




M.Sabyasachi


How to inject a Service into ViewModel ?

$
0
0

I'm a little confused about how to share a common property between several ViewModels.

I've read a solution about creating a service with the property and share it using Dependency Injection;

Basically, the shared property should be inject into viewmodel via iOC.

Can you give me a little sample of code on how to realize it?

Thank you all !

Any idea why Blend for Visual Studio is occasionally hidden from the Taskbar of Windows when Visual Studio is also open?

$
0
0

I can ALT-TAB to it and it shows as a blank rectangle in the ALT-TAB thumbnails when that issue occurs. Visual Studio 2015 RC Community, Windows 8.1 64. WPF. NET 4.6 Preview.

PS. I guess there might be another forum for it but I figured it's also specific to WPF development.

I can't reproduce it immediately. But it might happen after builds and runs. Not entirely sure.






c# wpf charting toolkit multiple line series

$
0
0

c# wpf chartingtoolkit

Q) how to check whether  added multiple line series in single or multiple chart have finish its working without backgroundworker??

for example following part of code:

                                     

                    LineSeries Series1 = new LineSeries();
                    LineSeries Series2 = new LineSeries();

     LineSeries Series3 = new LineSeries();
                    LineSeries Series4 = new LineSeries();

                    LineSeries Series5 = new LineSeries();
                    LineSeries Series6 = new LineSeries();
                    
                    Series1.ItemsSource = MyValue;    
                    LineChart1.Series.Add(Series1);
    Series2.ItemsSource = MyValue2;    
                    LineChart1.Series.Add(Series2);
                  
                    Series3.ItemsSource = MyValue3;               
                    LineChart2.Series.Add(Series3);

   Series4.ItemsSource = MyValue3;               
                    LineChart2.Series.Add(Series4);

Binding Style property in view model doesnot work

$
0
0

Hi,

I am binding Style property of my ToggleButton as shown in below code,

<ToggleButton x:Name="MyToggleButton" Style="{Binding MyToggleButtonStyleToUse, Mode=TwoWay, Converter={StaticResource stringToStyleConverter}, ConverterParameter='ZipStyle:DownloadZipToogleButtonStyle;WordDocumentStyle:OpenInWordToggleButtonStyle;*:OpenInWordToggleButtonStyle'}"x:FieldModifier="public" IsChecked="{Binding Path=IsOpen, ElementName=OpenInWordPopUp}"  Command="Save" CommandParameter="{Binding}" >
        </ToggleButton>

I have a converter which converts string to Style. I debugged the converter code also it is getting the correct Style. When the window is displayed the Style is not render to MyToggleButton control.

Please let me know if i am missing something in above code.

Regards,


Chetan Rajakumar

WPF Datagrid Column Header Text Wrap

$
0
0

I am currently using datatemplate that has a textblock to use text wrapping. However, when I shrink the column to wrap the text, I want to shift the data on the second line that's wrap to the right a couple of space. How can I achieve that. The column name is "ColorPhase1".

The output I want is:

I want to center the 1. When you wrap, the text is align all to the left

ColorPhase
        1
                                                                                                

 

The output I do not want is:

ColorPhase
1

 

 

 

 

 

 

 

 

 

                                     




Data connection issue in XBAP deployed over internet.

$
0
0

Hi, I am developing a XBAP application. Its main purpose it to host a legacy winform application so that user can use the legacy application through IE.

This legacy application is using the data block from an old version of Enterprise Library and it is working fine on its own. In the debugging mode of my XBAP application the whole thing works fine as well.

However, when I published the XBAP application to a web server and tested it from a browser, suddenly I was hit by some connection issue like the following

   at Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent.Fire(String connectionString)
   at Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataInstrumentationFacade.ConnectionFailed(String connectionString)
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.OpenConnection()
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteScalar(DBCommandWrapper command)
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteScalar(CommandType commandType, String commandText)

Anyone has any experience on this issue? BTW, the connection string is correct.


Bound to SystemCommands.ShowSystemMenuCommand doesn't work?

$
0
0

Hi,

It used to work with .NET 4.0 but not .NET 4.5. Why?

<Button VerticalAlignment="Top" HorizontalAlignment="Left" Padding="1" Cursor="Hand" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}" shell:WindowChrome.IsHitTestVisibleInChrome="True" Command="{x:Static SystemCommands.ShowSystemMenuCommand}" CommandParameter="{Binding ElementName=CalcWindow}"><Image Source="{Binding RelativeSource= {RelativeSource TemplatedParent}, Path=Icon}" Width="16" Height="16" shell:WindowChrome.IsHitTestVisibleInChrome="True"/></Button>

The button is disable for now,

Thanks,

Weera


custom page

$
0
0

hi, i want create a custom base page, for example with a grid with 3 row, the first with a heading label, the last with some buttons and the middle for to be used for insert the content.

I know that if i want inherit it i cant create it with xaml file so i created only the definition ( like MyBase : Page ) and inside i created grid etc etc programmatically.

I created correctly my inherited Page but i have a empty page in the design environment, so when i work for add the others components i dont see the grid etc etc, pratically i dont have the rendering of the base page in design mode.

sure i mistake something, what is the correct mode for have this?

thanx

WPF Application Styling

$
0
0

Hi,

Does anyone know of any tutorials or guides for styling controls on a WPF Application? 

Anyone know of any open source themes?

Thanks!

Saving Canvas to a .PNG File Problem

$
0
0

Hello,

I am experiencing a problem in my application to save a Canvas control object to a .PNG file.

Here is a sample code that reproduces the problem:

            Canvas sampleCanva = new Canvas();
            sampleCanva.Width = 1000;
            sampleCanva.Height = 1000;
            sampleCanva.Background = Brushes.AliceBlue;

            EllipseGeometry geo = new EllipseGeometry(new Point(500, 500), 300, 300);
            System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
            path.Stroke = Brushes.Red;
            path.StrokeThickness = 10;
            path.Fill = Brushes.Green;
            path.Data = geo;

            sampleCanva.Children.Add(path);

            RenderTargetBitmap bmp = new RenderTargetBitmap((int)sampleCanva.Width, (int)sampleCanva.Height, 96, 96, PixelFormats.Pbgra32);
            bmp.Render(sampleCanva);

            BitmapEncoder pngEncoder = new PngBitmapEncoder();
            pngEncoder.Frames.Add(BitmapFrame.Create(bmp));

            using (var stm = System.IO.File.Create(DateTime.Now.Ticks.ToString() + ".png"))
            {
                pngEncoder.Save(stm);

            } 

The file is created successfully, the size is greater than zero bytes, I can see the metadata and the size seem to be correct, but when I open the file there is nothing there.

Any ideas about what I am missing?

Thank you,

Igor


.NET Software developer for industrial internet and automation system.


WPF: can we automaticaly change the System.Windows.Documents.Table column width?

$
0
0

Our WPF application includes Report which uses System.Windows.Documents.Table.

There are maximum 96 columns. So we have to set the page width to be able to hold 96 columns.

However, some time the report includes 30 columns.

Since the table will evenly display columns with the page width, so the column width gets much bigger.

We could set column width in the xaml as following. This means we need to define 96 <TableColumn Width="80" />

<Table CellSpacing="0" BorderBrush="Black" BorderThickness="1"><Table.Columns><TableColumn Width="250" /><TableColumn Width="80" /><TableColumn Width="80" /><TableColumn Width="80" /><TableColumn Width="80" /><TableColumn Width="80" /><TableColumn Width="80" /><TableColumn Width="80" /><TableColumn Width="80" /></Table.Columns></Table>
We wonder if there is simple way to do that? thx!


JaneC

Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>