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

How to hide a particular Autogenerated columns of datagrid

$
0
0

Dear all,

I have a Datagrid which gets its column autogenerated from a data table.

What is the way to hide particular column from that datagrid. I do not want to remove the datcolomn from the binding source as I need to get that colomn in th results set but I simply need to hide it because it has no meaning for user, but internally it has.

The produce result is as below :

From that produce table, I need to hide columns name "RecordNb" and "PageCount"

The layout xaml is as below :

<DataGrid x:Name="gvParameterList"
						  VerticalContentAlignment="Center"
						  ItemsSource="{Binding}" IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow"
						  SelectionChanged="gvParameterList_SelectionChanged"
						  FontSize="14"
						  CanUserReorderColumns="False"
						  CanUserResizeColumns="True"
						  CanUserResizeRows="False"
						  CanUserSortColumns="True"
						  GridLinesVisibility="None"
						  RowHeight="35"
						  ColumnHeaderStyle="{DynamicResource DatagridColumnHeaderCustomTemplateStyle}"><DataGrid.CellStyle><Style TargetType="DataGridCell"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type DataGridCell}"><Grid Background="{TemplateBinding Background}"><ContentPresenter VerticalAlignment="Center" /></Grid></ControlTemplate></Setter.Value></Setter><Style.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Column.Status}" Value="0"><Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content.Text, Converter={StaticResource  CellColorConverter}}"/></DataTrigger></Style.Triggers></Style></DataGrid.CellStyle></DataGrid>

Any idea how to do that ?

regarsd


How to change the Datagrid Column Cells template based on its collomn databinding field value

$
0
0

Dear all,

I have the following Datagrid XAml layout :

<DataGrid x:Name="gvParameterList"
						  VerticalContentAlignment="Center"
						  ItemsSource="{Binding}" IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow"
						  SelectionChanged="gvParameterList_SelectionChanged"
						  FontSize="14"
						  CanUserReorderColumns="False"
						  CanUserResizeColumns="True"
						  CanUserResizeRows="False"
						  CanUserSortColumns="True"
						  GridLinesVisibility="None"
						  RowHeight="35"
						  ColumnHeaderStyle="{DynamicResource DatagridColumnHeaderCustomTemplateStyle}"><DataGrid.CellStyle><Style TargetType="DataGridCell"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type DataGridCell}"><Grid Background="{TemplateBinding Background}"><ContentPresenter VerticalAlignment="Center" /></Grid></ControlTemplate></Setter.Value></Setter><Style.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Column.Status}" Value="0"><Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content.Text, Converter={StaticResource  CellColorConverter}}"/></DataTrigger></Style.Triggers></Style></DataGrid.CellStyle></DataGrid>

The Datgrid colomns are autogenerated from a datatable result querry from a database and produce the follwoing grid data :

What I am trying to reach, is to be able to change the template of the Column named Status . When the value of this colum is 0, I need to display a green square in the cell and if it is 1 I need to display a red square.

I have try different things but could not get through, What is the way to achieve this ?

regards

Implementing sort on a column in listview using MVVM.

$
0
0

Hi to all,

I have a little program that has a ListView with a handful of columns.  I fill this ListView with data using bindings to a ObservableCollection.  It works great.  However, now I'd like to implement a sort on these columns in MVVM that would also display the up/down arrow on the column heading.  I thought I could bind a command to the column headings and simply sort the ObservableCollection in my ViewModel and this will automatically update the View.  However, how do I implement the up/down arrow beside the column heading without breaking MVVM?  I've seen implementations of this, but they use code-behind accessing elements of the View, something which I wanted to avoid.

Thanks,


MarcinMR

WPF ComboBoxItem with DataBinding

$
0
0
public partial class Window2 : Window
    {
        public eNumbers Tag { get; set; }

        public Window2()
        {
            InitializeComponent();

            ComboBoxItem cbo = null;

            Tag = eNumbers.Two;
            Array ord = Enum.GetValues(typeof(eNumbers));
            foreach (var item in ord)
            {
                cbo = new ComboBoxItem();
                cbo.Content = item;
                cbo.Tag = (eNumbers)item;
                if ((eNumbers)item == eNumbers.Three) cbo.IsEnabled = false;
                comboBox1.Items.Add(cbo);
            }

            DataContext = this;
        }

    }

  public enum eNumbers
    {
        One,
        Two,
        Three,
        Four
    }
<Window x:Class="TestDxControls.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:local="clr-namespace:TestDxControls"    ContentRendered="Window_ContentRendered"
        Title="MainWindow" Height="350" Width="525"><Grid Height="130" Width="316"><ComboBox Height="23" HorizontalAlignment="Left" SelectionChanged="comboBox1_SelectionChanged"
        Margin="78,12,0,0" Name="comboBox1" SelectedValuePath="Tag" SelectedValue="{Binding Tag}"
        VerticalAlignment="Top" Width="120" Background="Bisque" Foreground="Black"></ComboBox></Grid></Window>

Hi,

Please find the above code, Binding is not working in WPF ComboBoxItem.

Note: Please don't use ItemsSource Property.

Regards

Ahmed


Ahmed

September WPF Gurus Announced! Behold, the cream of the community! Join us!

$
0
0

The results for September's TechNet Guru competition have been posted!

http://blogs.technet.com/b/wikininjas/archive/2015/10/19/the-microsoft-technet-guru-awards-september-2015.aspx

Below is a summary of the medal winners for September. The last column being a few of the comments from the judges.

Unfortunately, runners up and their judge feedback comments had to be trimmed from THIS post, to fit into the forum's 60,000 character limit, however the full version is available on TechNet Wiki.

Some articles only just missed out, so we may be returning to discuss those too, in future blogs.
 

Guru Award BizTalk Technical Guru - September 2015  

Gold Award Winner

Janardhan BikkaBizTalk Server 2013 R2 integration with MS Dynamics CRM 2015Sandro Pereira: "Great topic, great article, well explained, lot of pictures, WOW keep coming! The layout/presentation of the article need to be treated and improved, but that I minor point regarding the quality of the article"
Abhishek Kumar: "Very good Article on CRM integration and well explained . Thanks for your Contribution ."
LG: "Material is interesting, but article content is too long."

Silver Award Winner

Rahul_MadaanPassing a message to BRE using Call Rules ShapeSandro Pereira: "The layout/presentation of the article need to be remade (different types of lettering, pictures could be better, pour layout of headers,…). This is a beginner article and steps explanations should be better detailed. This way the article is difficult to read and understand by their audience."

Guru Award Forefront Identity Manager Technical Guru - September 2015  

Gold Award Winner

Ryan NewingtonTake the guess work out of XPath with the Lithnet FIM Service PowerShell Module

Søren Granfeldt: "Excellent stuff"

Ed Price: "Great use of links for cross referencing!"

Silver Award Winner

Peter Geelen - MSFTFIM 2010: Verifying the Sync Engine Security Groups

Søren Granfeldt  "Nice work Peter"

Ed Price: "Good use of images and great to include the script sample!"

Bronze Award Winner

Wim BeckFIM2010: Localize Self Service Password Reset

Søren Granfeldt: "Thank you for this Wim!"

Ed Price: "Fantastic depth and great to read. Great article!"


Also worth a mention were the other entries this month:

Guru Award Microsoft Azure Technical Guru - September 2015  

Gold Award Winner

Michel JatobaStop and Start VMs with Automation on Microsoft Azure

JH: "Very good article with a detailed step-by-step guide. Love the amount of pictures."

Ed Price: "Great topic and great use of images! What a valuable article!"

Silver Award Winner

Samir FarhatCreate an URL Rewrite service via Azure Web App

JH: "Not an advanced topic, but most people struggle on it. Really good explanation."

Ed Price: "Perfect! I love this direct and thorough how to! Fantastic job on this!"

Bronze Award Winner

Ruud BorstMulti-tenant Azure AD federation with PowerShell

JH: "Interesting article. Would be better to have less text and a more detailed explanation of the script."

Ed Price: "Great scenario with a ton of explanation! More of a breakdown on the script would be good, but I still love the large amount of details here! Great job!"


Also worth a mention were the other entries this month:

Guru Award Miscellaneous Technical Guru - September 2015  

Gold Award Winner

Rishabh BangaFull Home Automation with Azure & Voice Assistance using Intel Galileo Gen 1 & Windows 10Durval Ramos: "This is an inspiring and practical article, which combines multiple platforms and allows you to create a very useful solution."
Richard Mueller: "A very interesting and potentially useful idea. Good detailed steps, with lots of code. Good images and great use of Wiki guidelines."

Silver Award Winner

Pooja BaraskarSmart Baby Monitor with Intel Edison and UbidotsDurval Ramos: "This article is interesting and presents the "simple content". It's very easy to understand what must be done, but need to add "References" section to indicate where his work was inspired."
Richard Mueller: "What a great idea. Very good images and detailed explanation."

Bronze Award Winner

Carmelo La MonicaPart one: tools for debugging in Visual Studio 2015Durval Ramos: "This article presents a resource that can be the difference between a successful solution and a project that should be reformed. Very good"
Richard Mueller: "Good introduction to VS 2015. Good images and explanation. Grammar needs works."


Also worth a mention were the other entries this month:

Guru Award SharePoint 2010 / 2013 Technical Guru - September 2015  

Gold Award Winner

Dan ChristianCloser look at SharePoint Server 2016 PreviewAshutosh Singh: "Thanks Dan"
TN: "A good wrap-up in SharePoint 2016"

Silver Award Winner

Inderjeet Singh JaggiSharePoint 2016 Farm configuration issue on Windows Azure Virtual MachineAshutosh Singh: "This is very good"
TN: "An interesting post"

Bronze Award Winner

Dan ChristianInstalling the Office Online Server PreviewTN: "Great article on how to set up Office Online Server including some common issues"
Ashutosh Singh: "Thanks for this Dan"


Also worth a mention were the other entries this month:

Guru Award Small Basic Technical Guru - September 2015  

Gold Award Winner

Emiliano MussoPrime Number Factorization with Small BasicMichiel Van Hoorn: "Put your math to practice. Great write up. "

Silver Award Winner

Ed Price - MSFTSmall Basic: Automatic Type ConversionMichiel Van Hoorn: "Useful if you are starting juggling with numbers in Small basic"

Guru Award SQL BI and Power BI Technical Guru - September 2015  

Gold Award Winner

Maruthachalam KCreating reports using OData Feed in Power BIRB: "Nice explicative walkthrough."
JS: "Great article, I would want one word concerning security of ODATA feeds in the article as well."
Durval Ramos: "This article is very well illustrated, but need to add the "References" and "See Also" sections to valuable this article. Additional information is needed to validate your content"
PT: "This post demonstrates the ease and utility of Power BI with an OData data source. Thank you for this valuable contribution."


Also worth a mention were the other entries this month:

  • SSRS: Join data from different SSRS data sources into data set by sergey vdovin
    PT: "At first I had mixed feelings about promoting these techniques as a best practice, given the level of complexity. However your approach to this challenging problem well executed and clearly explained. Thank you for posting this useful information."
    RB: "Not much information here, apart from link to github projects"
    OT:"I personally don´t see any greater benefit in writing a separate article and referring an already existing one without pointing out really new stuff. The old one is pretty good and although the author does not get much love updating this, he should in order to have the thing in one place."
    AN: "The content is not complete and the "Solution" section was written in another article. This article's very confused."

Guru Award SQL Server General and Database Engine Technical Guru - September 2015  

Gold Award Winner

Martin SmithClustered and Nonclustered indexesJS: "Instead of "to explicitly include all non key columns" => "to explicitly include one or more non-key columns". Liked the spatial representation!"
AM: "Simple and concise explanation. Great illustration as a plus."
Durval Ramos: "A good presentation about how each index works."

Silver Award Winner

Yashwant VishwakarmaSQL Server Databases: Back To BasicsJS: "Although nothing really leading edge, a good start for new beginners in one place. I would want more references to MSDN articles in order to enable the reader digging in a bit deeper."
Durval Ramos: "This article's a good summary about "some" SQL Server features and has good images, but I believe that can be improved if add more details in each database type"

Guru Award System Center Technical Guru - September 2015  

Gold Award Winner

Adin ECluster Patching Showdown: Comparing SCVMM and SCCM Patching

Peter Laker: "An excellent and in depth article"

Ed Price: "Wow! Fantastic details!"

Silver Award Winner

Foothill1SCSM Data Warehouse Search Tool

Peter Laker: "Thanks for the contribution Foothill1"

Ed Price: "Good topic. The example is helpful."

Guru Award Transact-SQL Technical Guru - September 2015  

Gold Award Winner

Martin SmithUnpivot vs ApplyManoj Pandey: "Very informative post about usage of UNPIVOT and/vs CROSS APPLY. But you could have given more details on the top of what are you covering in your post."
Durval Ramos: "This is a good article, but need add "References" and "See Also" sections to additional content based on their original idea (post or article)."
Richard Mueller: "Good use of Wiki guidelines. I liked the images. A See Also and Other Resources could be useful."

Guru Award Universal Windows Apps Technical Guru - September 2015  

Gold Award Winner

Rishabh BangaFull Home Automation with Azure & Voice Assistance using Intel Galileo Gen 1 & Windows 10

JH: "What an article! Needs just a little formatting. Love the whole IoT stuff."

Ed Price: "This is truly beautiful! The hardware images are helpful, the UI images are great, and the code is formatted very well! Plus the topic is ambitious and fun!"

Silver Award Winner

Afzaal Ahmad ZeeshanBuilding camera app with library in Windows 10

JH: "Very detailed explanations and a lot of code snippets. A good one."

Ed Price: "I love how this is a specific app type. Very useful for developers!"

Bronze Award Winner

SYED SHANUWindows 10 Universal App Development for Name Puzzle Game

JH: "Fun article. Will try this one myself."

Ed Price: "What a fun game! Fantastic execution on this article! Great job!"

Guru Award Visual Basic Technical Guru - September 2015  

Gold Award Winner

Emiliano MussoBasis of Neural Networks in Visual Basic .NETCarmelo La Monica: "Fantastic!!! Perfect article, great code snippet and theory of Neutral Networks. Congrats!"
Richard Mueller: "Very interesting topic and well researched. Would be great to play with this. Grammar could be improved."
MR: "Great article!"

Silver Award Winner

.paul.CheckBoxColumn Select All DemoMR: "Simple but very effective!"
Carmelo La Monica: "Great topic and useful for to extend function on Datagridview."
Richard Mueller: "A well written article. I would like to see more links to other references."

Guru Award Visual C# Technical Guru - September 2015  

Gold Award Winner

SYED SHANUDataGridView Gantt style chart using C# WinformCarmelo La Monica: "Very interesting topics and very and useful for to extend function on Datagridview. Congrats!"
Jaliya Udagedara: "Explains a solution to a specific problem. Love the fact that sample code is available to download. A bit of formatting is needed in the article."

Silver Award Winner

Ken CenerelliUnderstanding the Visual Studio AssemblyInfo ClassJaliya Udagedara: "Well explained the topic for well formatted. It’s just perfect."
Carmelo La Monica: "Congratulations, article very detailed in all parts, useful for to understand AsssemblyInfo Class, good code snippet and images."

Bronze Award Winner

Gaurav Kumar AroraC#: How to check whether API server is up or downJaliya Udagedara: "Little bit of code formatting and a link to download the sample code will help readers a bit more."
Carmelo La Monica: "Great topics and very useful for to understand if api server in up o down. Congrats!"


Also worth a mention were the other entries this month:

  • MVC Web API And AngularJS: Are You Genius Game bySYED SHANU
    Carmelo La Monica: "Interesting, i don't have experience on Asp.Net, but article very interesting, good image and code snippet."
    Jaliya Udagedara: "Explains a specific application. Love the fact that a lot of images is used and sample code is available to download which helps the readers. A bit of article formatting is needed."
  • Little More Information On Casting and Type Checking in C# byIsham Mohamed
    Jaliya Udagedara: "Explains the topic of the article in detail. If we can have little bit of formatting in the article, then it will be perfect."
    Carmelo La Monica: "Sometime is a problem for casting Object, but with this article we can to understand how to convert correctly an object or variable. Congrats!"
  • ASP.NET MVC HangFire - Execute Jobs in Background using SQLServer by João Sousa
    Jaliya Udagedara: "I would rather change the title of the article to “Configure Hangfire in an ASP.NET MVC Application”, because that is what explained in the article. Good job!"
    Carmelo La Monica: "Great content, and useful image and code snippet. Congratulations!"
  • MVC Web API and Angular JS For Word Puzzle Game bySYED SHANU
    Carmelo La Monica: "Same comment for MVC Web API And AngularJS: Are You Genius Game. Congratulations!"
    Jaliya Udagedara: "Explains a specific application. Love the fact that a lot of images is used and sample code is available to download which helps the readers. A bit of article formatting is needed."

Guru Award Wiki and Portals Technical Guru - September 2015  

Gold Award Winner

Ken CenerelliVisual Studio 2015 PortalDurval Ramos: "A great portal. Very useful !!!"
Richard Mueller: "Outstanding example of usage of Wiki Guidelines. And a great collection of links."

Guru Award Windows PowerShell Technical Guru - September 2015  

Gold Award Winner

Curtis SmithPowerShell: Directing DNS with PowerShellJan Egil Ring: "My favorite this month"
Richard Mueller: "A great article with excellent explanations and good use of Wiki guidelines. Good step by step detail. Some of the topics could go in another article, or you could reference existing references. For example, documentation of string methods and explanation of $_."

Silver Award Winner

Peter Geelen - MSFTPowerShell: Event viewer statisticsRichard Mueller: "Lots of code, but also lots of comments. Good use of Wiki guidelines. Great to give credit. Maybe could use some more discussion."
Jan Egil Ring: "Excellent work!"

Bronze Award Winner

Sravan EatoorPowerShell: Dynamic Form - All In One ToolJan Egil Ring: "Thanks Sravan"
Richard Mueller: "An interesting idea that might prove useful where organizations have collected many scripts."

Guru Award Windows Presentation Foundation (WPF) Technical Guru - September 2015  

Gold Award Winner

Andy ONeillMVVM Step by Step 2LL: "Good article!"
Peter Laker: "Nice work as always Andy!"

Silver Award Winner

Tom MohanHierarchical Binding Using HierarchialDataTemplateLL: "Nice 101"
Peter Laker: "Thank you Tom!"

Guru Award Windows Server Technical Guru - September 2015  

Gold Award Winner

Richard MuellerActive Directory: Allow Linked Multi-Valued Attributes to use LVRMark Parris: "Information to show that just by raising the FFL, there is still more work that may need to happen."
JM: "This is an excellent article, thanks for your continued contributions."

Silver Award Winner

Darshana JayathilakeFile Server Migration ToolkitMark Parris: "Useful information now that Windows 2003 is no longer a supported platform."
JM: "This is a great articled that will help admins migrate WS03 file servers, nice work."

Bronze Award Winner

FZBWSUS: the underlying Connection was closed during Server cleanupMark Parris: "Good tidbit of information around WSUS and the command line."
JM: "This is a very good article that will help admins clean up their WSUS databases"

As mentioned above, runners up and comments were removed from this post, to fit into the forum's 60,000 character limit.

You will find the complete post, comments and feedback on the main announcement post.

Please join the discussion, add a comment, or suggest future categories.

If you have not yet contributed an article for this month, and you think you can write a more useful, clever, or better produced wiki article than the winners above, here's your chance! :D

Best regards,
Pete Laker

More about the TechNet Guru Awards:


#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over toTechNet Wiki, for future generations to benefit from! You'll never get archived again, and you could win weekly awards!

Have you got what it takes o become this month's TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!


Transfer click event from checkbox to a button.

$
0
0

Hello. I need some help with a small

        private bool OnSave(bool val)
        {
            bool _success = true;
             if(val == true)
                 return _success;
             else
             {
                 _success = false;
                 return _success;
             }
        }

        private void cb_emp_hist_Click(object sender, EventArgs e)
        {
            if(cb_emp_hist.IsChecked.Value)
                OnSave(true);
            else
                OnSave(false);
        }

problem. I have a button that brings data from SQL to a datagrid and a checkbox. If the checkbox is checked I should bring data with a condition (WHERE fld_status = 0). But I dont know how can I transfer the checkbox click event to the button.

Can you please help me? Here is what the code I already have, and from here I dont know how to receive data from Onsave to the button click event.

WPF CheckBox not displaying checked in Window Server 2012. Is this bug or feature?

$
0
0

Hi,

In Window Server 2012 WPF check box default behavior is differnt from Winsow 7. I win7 if I apply foreground colour in check box then it apply only on check box caption colour but in window 2012 it apply on caption color and check colour so due to this if I set foreground white then checkbox does not display checkecd in server 2012 while it is checked. I know the solution but i want to figure out this is bug or feature or missing somthing in sever 2012, Please guide me I need help urgently. Thanks in advance.

Thanks,

Anil

Control like Word style selector

$
0
0

Hi everybody,

I'm working on a application C#/WPF (.NET 4.5) that implements Ribbon controls.

But there are 2 things I could not implement. I'd like to have a control in a ribbon toolbar similar to the Word style selector :

And the other control I'd like to implement is a button like the one we have at the bottom-right corner of each RibbonGroup :

Do you know if that is possible natively ? and how ?

Thanks in advance for your help



Blend WPF Animation : Animation path geometry automatically scale based on window resize

$
0
0

I have animated an object along a path using blend storyline. I am animating its X coordinate of the object such that it moves in a straight line between two images. The entire placement is done on a grid where left image is bound to left margin and right image is bound to right margin so that when window is resize the images move accordingly. PFB the code :

<UserControl.Resources><Storyboardx:Key="LineAnimation"RepeatBehavior="Forever"><DoubleAnimationUsingKeyFramesStoryboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"Storyboard.TargetName="path"><EasingDoubleKeyFrameKeyTime="0"Value="0"/><EasingDoubleKeyFrameKeyTime="0:0:4"Value="462.545"/></DoubleAnimationUsingKeyFrames></Storyboard></UserControl.Resources><GridHeight="0"Width="784.001"><Pathx:Name="path"Fill="#FFF4F4F5"HorizontalAlignment="Left"Height="15.073"Stroke="Black"VerticalAlignment="Top"Data="M0.55429077,0.50088078 C0.56195831,0.50516075 0.56729126,0.523664 0.56729126,0.52366364 29.662338,1.36954 29.320824,1.031827 29.320824,1.0318269 29.320618,14.573003 29.320824,14.573003 29.320824,14.573003 1.0815125,13.726863 1.0815125,13.726863 1.0815125,13.726862 0.33274078,1.1378824 0.50061798,0.47091863 0.55429077,0.50088078 z M35.375294,0.5008778 C35.382957,0.50515866 35.388294,0.52366197 35.388294,0.52366215 64.483337,1.3695344 64.141821,1.0318248 64.141821,1.0318255 64.141616,14.573002 64.141821,14.573002 64.141821,14.573003 35.902512,13.726866 35.902512,13.726866 35.902512,13.726865 35.153748,1.1378781 35.321621,0.47091594 35.375294,0.5008778 z M70.196289,0.50087637 C70.203955,0.50515676 70.209291,0.52366006 70.209291,0.52366072 99.304325,1.3695328 98.962814,1.031823 98.962814,1.0318225 98.962606,14.572999 98.962814,14.572999 98.962814,14.572999 70.723519,13.726864 70.723519,13.726864 70.723518,13.726864 69.974748,1.1378755 70.142621,0.47091386 70.196289,0.50087637 z"Stretch="Fill"Width="99.463"RenderTransformOrigin="0.5,0.5"Margin="92.585,84.488,0,-99.561"><Path.LayoutTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransform/><TranslateTransform/></TransformGroup></Path.LayoutTransform><Path.OpacityMask><LinearGradientBrushEndPoint="0.5,1"StartPoint="0.5,0"><GradientStopColor="Black"Offset="0"/><GradientStopColor="White"Offset="1"/></LinearGradientBrush></Path.OpacityMask><Path.RenderTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransform/><TranslateTransform/></TransformGroup></Path.RenderTransform></Path><Imagex:Name="image1"Height="192.829"Source="/HackingHttp_Get2;component/Images/server1.png"Stretch="Fill"VerticalAlignment="Center"HorizontalAlignment="Right"Width="171"ScrollViewer.HorizontalScrollBarVisibility="Auto"Margin="0,2.259,54.401,-195.088"/><ImageSource="/HackingHttp_Get2;component/Images/computer.png"Stretch="Fill"Margin="3.44,8.054,610.763,-197.568"/><TextBlockTextWrapping="Wrap"Text="Hitting Server"FontSize="18.667"RenderTransformOrigin="0.5,0.5"Margin="33.8,62.953,637.221,-87.783"><TextBlock.RenderTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransformAngle="-9.503"/><TranslateTransform/></TransformGroup></TextBlock.RenderTransform></TextBlock></Grid>

What I would like to do is scale the X coordinate in the animation ,instead of fixed value, so that when the window size changes the animation changes it proportions as well, adapting to that of the window. Something like this :

<UserControl.Resources><Storyboardx:Key="LineAnimation"RepeatBehavior="Forever"><DoubleAnimationUsingKeyFramesStoryboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"Storyboard.TargetName="path"><EasingDoubleKeyFrameKeyTime="0"Value="{Binding to image1 right position}"/><EasingDoubleKeyFrameKeyTime="0:0:4"Value="{Binding to image2 left position}"/></DoubleAnimationUsingKeyFrames></Storyboard></UserControl.Resources>

I know there is Viewbox that does the resizing , but when we use the same, it resizes the images on window instead of scaling the animation thus giving the illusion .

Simply put, I would like my animation to scale according to the size of the Window. Is there a way to achieve this ?

DataGrid foreground is transparent after loosing focus

$
0
0

The DataGrid foreground is loosing color after i enter the data and press TAB or ENTER keys.

What needs in XAML to fix this?

<UserControl.Resources><Style x:Key="DataGridRowStyle" TargetType="DataGridRow"><Style.Triggers><DataTrigger Binding="{Binding IsNewRecord,Mode=TwoWay}" Value="True"><Setter Property="Background" Value="Green"/><Setter Property="Foreground" Value="White"/></DataTrigger></Style.Triggers></Style></UserControl.Resources><Grid Background="Transparent" Margin="0,22,0,23" Height="250"><DataGrid  x:Name="ViewDataGrid" ItemsSource="{Binding IData, Mode=TwoWay}" Margin="0,0,0,10" RowStyle="{StaticResource DataGridRowStyle}"
                   HeadersVisibility="None" AutoGenerateColumns="False" RowHeaderWidth="0" ClipToBounds="True" HorizontalScrollBarVisibility="Disabled"><i:Interaction.Behaviors><cls:ScrollIntoViewBehavior/></i:Interaction.Behaviors><DataGrid.Resources><SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="DarkGray"/><Style TargetType="DataGridCell"><Setter Property="ToolTip"><Setter.Value><StackPanel><TextBlock Text="{Binding ItemA}" /><TextBlock Text="{Binding ItemB}" /></StackPanel></Setter.Value></Setter><!--<Setter Property="Foreground" Value="Black"/>--></Style></DataGrid.Resources><DataGrid.Columns><DataGridTextColumn Binding="{Binding ItemA}" Width="152"/><DataGridTextColumn Binding="{Binding ItemB}" Width="153"/></DataGrid.Columns></DataGrid></Grid></UserControl>
CodeBehind:
  public CaseData()
        {
            _selectedDataRow = new CaseDataItem();
            InitializeComponent();
        }

        [InjectionConstructor]
        public ViewData(ICaseDataViewModel viewModel)
            : this()
        {
            DataContext = viewModel;
            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick +=new EventHandler(timer_Tick);
            timer.Interval = TimeSpan.FromSeconds(2);
            timer.Start();
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            ViewDataGrid.RowBackground = new SolidColorBrush(Colors.Transparent);
            var cellStyle = new Style { TargetType = typeof(DataGridCell) };
            cellStyle.Setters.Add(new Setter(ForegroundProperty, Brushes.Black));
        }
     

Also the Dispatcher foreground cell color property in the code behind is not working




WPF c# i have the file open in my software when i try to send a second xps file to the document viewer

$
0
0
documentViewer1.Document =
                                ConvertToXPSDoc(newXPSDocumentName, newXPSDocumentName).GetFixedDocumentSequence();



private XpsDocument ConvertToXPSDoc(string wordDocName, string xpsDocName)
{
    try
    {

        XpsDocument xpsDoc = new XpsDocument(xpsDocName, System.IO.FileAccess.Read);
        return xpsDoc;
    }
    catch (Exception exp)
    {
        string str = exp.Message;
    }
    return null;
}

How to build OneNote windows like in WPF

$
0
0

Dear all,

We are trying to build an application which is based on sharing ideas betwen different person on the same windows area.
The application will run on a big table touch and idea is to bring to users collaborative user interface on placing ideas on a project.

The starting point is a floor plan of a house from Arhichitect and then people around the table discuss all together and interface around the table on this floor plan.

We have implement the possibility for instance for users to be able to draw some information on the floor by using an InkCanvas on top of the floor plan picture.

The next steps we try to reach is to be able to place some note the user can place on the working area by dragging or droping.

Quite similar effect that we can see on Microsoft OneNote.

What is the way to create and place those kind of information on the Inkcanvas, that we can freely move at any position ?

Thnaks for your advise

regards

Does anyone have experince on implenting NFC on a WPF app in C#

$
0
0

Dear all,

We are trying to implement NFC feature in one of our application.

The issue we met is that we have no problem to find out reader or writer device, but for interfacing with the device we do not want to be dependant of the NFC brand or device tye, simply because in some situation we cannot impose a particular device to final customer.

Does some of you have already implement such device in WPF application and if yes in which way the communication with the device was done ?

- Device SDK or any kind of generic c# open library around ?

Thanks for sharing

Regards

How to create hotSport on a given picture in order to isolate an area of the picture

$
0
0

Dear all,

We have a given picture of any kind that we display as the main background in a WPF application.

From that picture, we would like to be able to drawn an closed area on this picture which then represent a kind of layer.

At that time , user can select this area and fill all this area with a color.

Imagine for instance a house plan, where we have rooms represented. Then we have different color on the application where user can select and paint specific area of the plan, like painting the bedroom floor with a pattern.

The issue is that we do not have in advance the floor plan, which can change based on customers. So we try to generate directly those area with touch what ever the picture is.

What is the way from a given picture to slice it in different layer shape which can then be a separate object ?

Thanks for advise or sample

regards

An unhandled exception of type 'MS.Internal.PtsHost.UnsafeNativeMethods.PTS.SecondaryException' occurred in PresentationFramework.dll

$
0
0

Hello, 
Im getting an exeption when trying to Invoke an action. Im trying to update a Paragraph object. 
Here is the code which suppose to update the Paragaph but fails to do it: 

Run r = new Run((string)name + Environment.NewLine);
r.Foreground = Brushes.Green;
Dispatcher.Invoke(new Action(() => { currentlyOnlineParagraph.Inlines.Add(r); }), DispatcherPriority.Normal);

But im getting this error: 

An unhandled exception of type 'MS.Internal.PtsHost.UnsafeNativeMethods.PTS.SecondaryException' occurred in PresentationFramework.dll

Im not even sure that the error occures in that code section, but when I remove it the program works fine, so I assumed it was the problem. 
Heres a screenshot of the problem: http://prntscr.com/8xxfdc


WPF c# Insert image Form code to WPF. I am having difficulty transfering the c# code to WPF

$
0
0
public void InsertImageTool_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.Title = "RTE - Insert Image File";
            openFile.DefaultExt = "rtf";
            openFile.Filter = "Bitmap Files|*.bmp|JPEG Files|*.jpg|GIF Files|*.gif";
            openFile.FilterIndex = 1;
            openFile.ShowDialog();

            if (openFile.FileName == "")
            {
                return;
            }

            try
            {
                string strImagePath = openFile.FileName;
                Image img;
                img = Image.FromFile(strImagePath);
                Clipboard.SetDataObject(img);
                DataFormats.Format df;
                df = DataFormats.GetFormat(DataFormats.Bitmap);
                if (this.richTextBox1.CanPaste(df))
                {
                    this.richTextBox1.Paste(df);
                }
            }
            catch
            {
                MessageBox.Show("Unable to insert the image format selected.", "RTE - Paste");
            }
        }

WPF-Designer-friendly custom canvas

$
0
0

I created a class that inherits Canvas, and overriden ArrangeOverride() to position elements based on some new attached properties in addition to Canvas.Left and Canvas.Top

However, when I drag child elements in the WPF designer (Blend or Visual Studio / Cider), it attempts to set Canvas.Left and Top to values that would constitute to a correct position have I not implemented custom positioning rules. This leads to child control jumping to an incorrect position the moment I start dragging it.

So supposedly I need to tell WPF how to convert onscreen coordinates back to property values, but how do I do that?


I understand how to create and register a design-time helper assembly, and looked through tutorials on implementing custom adorners, but was unable to find a way to influence an existing built-in sizing/moving adorner of the designer.

Any clues, urls, books, etc. are welcome -- I've been searching for weeks with no results!

Please do not suggest RenderTransform -- it works, but leads to other glitches with the designer -- however that's a topic for another question

Load USerControl once first one has finished

$
0
0

I have a user control for my StatusBar which reads settings for a file and loads the data (including a database connection).
The problem is that I want to load a second user control that reads for the database using the connection information in the first user control. Therefore, I want the second usercontrol to only load one the first has loaded the database information (Server, Database etc) and ensured the connection is available.

How do you only load the second control once the first has completely finished loading?

Thanks

Translate and rotate programmatically in designer-friendly way

$
0
0

I created a class that inherits Canvas. I would like to be able to rotate and translate children from my canvas' code without affecting Canvas.Left, Canvas.Top and ArrangeOverride()

All tutorials about rotation I found suggest setting children' RenderTransform property from the code, which works in runtime, but WPF designer (Expression Blend and Visual Studio / Cider) tends to overwrite it:

1) if a child control's right resize thumb is accidentally dragged beyond the left border (and vice versa), reversing the control, designer creates a rendertransform to apply ScaleX=-1

2) if I accidentally rotate the control

3) if I accidentally drag rotation center thumb from its default position

4) if I manually set RenderTransform for any reason

This replaces the TransformGroup I assigned to the control with what was serialized from newly generated XAML, which means I need to either create a brand new TransformGroup every time the control is updated (not good for performance) or try to somehow check if my group was replaced or altered.

Both options do not work reliably, which leads to design-time position to be different from runtime one until all RenderTransfrom properties are deleted from XAML code and the design window is closed and opened again.

The best I could do is to throw an exception if an unwanted change of RenderTransform is detected, prompting to fix the problem with Ctrl+Z, but even that sometimes leaves the control in glitched state for some strange reason.

Other people also get very confused when they rotate anything inside my canvas the way they are used to.

So the question is: is there a way to apply a Transform without affecting RenderTransformProperty from canvas's code? Such as from OnRender(), probably? Or somehow access protected Visual.Transform of a child element?

Any clues would be appreciated.

Please do not suggest LayoutTransform - I would like rotation to apply after the layout step is done. Also, LayoutTransform ignores translation, so I need some other way to move things around.

Is it possible to get different ink attributes on the same InkCanvas

$
0
0

Dear all,

I was wondering if it is possible to have different Ink attribute on the same inKCanvas ?

Scenario that I imagine is the following :

Lets say we have a big multitouch screen where we have a white bacground representing a drawing paper.

Then at each side of the paper we have 4 kids that they would like to draw all together a great painting.

SO idea is that is it possible that Kids1 select Green color and Kids 2 seleect Red color and both of them paint respectivly in green and red on same board ?

We have a screen which support 60 multitouch point so that is a real scenario

regards


Viewing all 18858 articles
Browse latest View live


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