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

Am changed as opacity of water mark then print the crystal report it has displayed as original water mark in wpf

$
0
0

Am changed as opacity of water mark then print the crystal report it has displayed as original water mark .

we are created image as  byte array then read that array.


wpf listview background color

$
0
0
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="452" Width="614"><Grid x:Name="gridHome" HorizontalAlignment="Left" Height="300" Margin="0,10,-52,-318" VerticalAlignment="Top" Width="600"><ListView x:Name="lsvOrder" Height="300" Margin="0,10,0,-10" VerticalAlignment="Top"><ListView.View><GridView><GridViewColumn Header="No" Width="60"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding NUMBER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Order No" Width="120"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding ORDER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="table" Width="120" ><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding TABLE}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Order Info" Width="150"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding ORDER_TIMER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Table Info" Width="150"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding TABLE_TIMER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn></GridView></ListView.View></ListView><Button Content="Button" HorizontalAlignment="Left" Height="65" Margin="20,329,0,-94" VerticalAlignment="Top" Width="75" Click="Button_Click"/></Grid></Window>


public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            lsvOrder.Items.Add(new ListViewData("1", "0001", "T1", "Timer1", "Timer4"));
            lsvOrder.Items.Add(new ListViewData("2", "0002", "T2", "Timer2", "Timer5"));
            lsvOrder.Items.Add(new ListViewData("3", "0003", "T3", "Timer3", "Timer6"));
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }
    }

    public class ListViewData
    {
        public ListViewData(string col1, string col2, string col3, string col4, string col5)
        {
            NUMBER = col1;
            ORDER = col2;
            TABLE = col3;
            ORDER_TIMER = col4;
            TABLE_TIMER = col5;
        }

        public string NUMBER { get; set; }
        public string ORDER { get; set; }
        public string TABLE { get; set; }
        public string ORDER_TIMER { get; set; }
        public string TABLE_TIMER { get; set; }
    }

Hello~

How to: Alternate the Background Color for Rows in a ListView?

Note :

- I want Code(C#).

- Colors arechanged by acertain time.

        Timer1 > 60sec : Red , Timer1 > 120sec : Green ...

Color SettingsUse theColor table.(ex: #ffffffff) <- Customer choice(color picker)

Please answer. 

Printing Issues in Windows 10

$
0
0

At my company we use Document Viewers containing FixedDocuments wrapping UserControls to display forms to our users.  It works great, but on Windows 10 we have noticed a couple of printing related issues that we just can't figure out:

  1. One of the forms will simply not print from Windows 10.  We have tried it on two different computers with two different printers (one printer shared by both machines on a network and both of different manufacturer).
  2. The lines of some simple path geometry objects are not printing.

I have confirmed that these issues occur in both our application and when the xaml is simplified enough to be loaded into and printed from Internet Explorer.

For the first issue the form prints fine on the shared printer from windows 7.  The only clue I have been able to find as a possible cause is that the form's background (rendered as a DrawingBrush on a canvas' background) has a umber of very deeply nested Drawing groups (at least 20 deep); each of which draw a single line.  The xaml was created by a utility of ours and not by hand.

The only other clue I have been able to gather is that when printing the form on one of the printers from Internet Explorer we actually got a print error in the Windows event viewer operational print logs.  While it didn't say much; the driver isolation event did return an error code 0x103 (on a local Brother USB connected printer).

The path geometry for the second issue is as follows:

<GeometryDrawing x:Name="path26" ><GeometryDrawing.Pen><Pen Brush="#FF231F20" Thickness="0.1" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter" /></GeometryDrawing.Pen><GeometryDrawing.Geometry><PathGeometry FillRule="Nonzero" Figures="M351.001,579L361.001,579 361.001,567 351.001,567 351.001,579z" /></GeometryDrawing.Geometry></GeometryDrawing>

This same shape is repeated in several places, and one or more of the sides of the box (which is what the PathGeometry described above is) are missing when printing.  The same line segments are missing when printed from both of our printers.  I've tried making the lines thicker, and while that does make the missing sides appear, the sides that were always printed don't change and look strange.

Neither of these issues occur when printing to a virtual printer like the Adobe PDF Printer.  When printing to the Adobe PDF printer the form that doesn't normally print will and all box sides will be present in the resulting PDF file.

I can work around both of these issues, but that would mean touching a whole lot of code (we have a lot of forms) and we would really like to understand what is going on and not just stick a band aid on it.  

If someone else has encountered these issue or has any idea as to what is going on and can shed some light on these issues that would be very helpful.


Set focus on PasswordBox Problem

$
0
0

I want to show  password box with typing cursor for that we can start direct typing without setting cursor.

<PasswordBox  Name="passwordTextbox" Grid.Row="1" Grid.Column="1" Margin="5,35,5,5" Width="280"

Height="27" app:PasswordBoxAssistant.BindPassword="true"

app:PasswordBoxAssistant.BoundPassword="{Binding TechUserModel.UserId, Mode=TwoWay, ValidatesOnDataErrors=True,

UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"></PasswordBox>

I am setting focus by programming

passwordTextbox.Focus();

It's showing cursor but not start typing without setting cursor again. Can I show PasswordBox with default running cursor ? please provide any one solution.





Sycronize two task in my WPF program

$
0
0

hello,

my program thougth a start button must be execute a StartMethod with this requirements:

- sends data to my hardware adapter in a loop, only if listen task below, signal of send next frame.

- must be run a task (is mandatory from my hardware adapter) that listen answers

who tells me how to set 2 task with pseudo code ?

thanks

How to detect 3 silmutaneous touch point in my WPF application

$
0
0

Dear all,

I am building a WPF application concept in order to use tangible object. I have design an object which is represented as below :

Red conductive points allows me to identify if it is an object or not, and green points alows me to identify and object ID.
When this object is place on a capacitive touch screen, it simulate touch input.

So based on the Red conductive point of the object, I need to detect them from my wpf application touch stack input.
I have trouble to do that , what I need to do is the follwoing :

1 - I need first to detect what are the 3 most outise touch points from green and red
2 - when I have detected the 3 point, then I need to calculate the distance between each 3 points
3- if the 3 distance are corresponding by the triangle formed by the 3 red dot, then I have detected an object and not a finger.

My scool is far awayand could not remeber how can I appraoch this to know how to catch my object

Thanks for any help and advise

regards

Animation does not go to the [To] value

$
0
0

I am now doing animation (see previous post) in the DC rather than the app code.  It all works but I noticed that with several animations the position of the items being animated "degrades".  By that I mean that the animation completes (raises Completed event) but the value of the [To] parameter of the animation is not met.

I put in a bunch of Debug statements to find this out and the following is a sample of the problems.

*** Switch Items ***
Switch KD - 225 with 10S - 425

Animating KD from 225 to 425
Animating 10S from 425 to 225
Animation complete in object
Supposed to be = 425 but is 411.79332

Animation complete in object
Supposed to be = 225 but is 238.20668

First line is showing which two items are switched using the animation.  Then the next two lines show the starting value of the animated value and the destination value.  This is followed by the values when the Completed event fires.  As you can see the values are "close" but not exact which causes the display to become somewhat screwed up as the number of animations increases.  I have a work around by putting the desired value in the DC and when the animation is complete simply changing the animation property to that value.

Question is why does the animation not continue until the [To] value is met?


Lloyd Sheen

HOw to mimimize a windows started with the Process

$
0
0

Dear all,

From a WPF application I am starting IE to a given adress as follow :

IexplorerProcess = new System.Diagnostics.Process();
                        IexplorerProcess.StartInfo.FileName = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe";
                        IexplorerProcess.StartInfo.UseShellExecute = true;
                        IexplorerProcess.StartInfo.Arguments = "http://localhost/reports/";
                        IexplorerProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;

                        IexplorerProcess.Start();

The problme with that is tha normally my explorer window should be send to be Minimized, but in fact it does not.

Any idea how to minimize it correctly ?

regards


Auto adjustable width of rectagle having a textblock depending on text

$
0
0

Hi,

I want a text block inside a rectangle. The below code works fine.
But here I have to specify the width and height.

My applycation is multilingual and for some language the textblock text might be longer.
How to make sure that the rectagle is adjusted according to the text in text block?

<Grid>
            <Rectangle Fill="Red" Width="80" Height="80"/>
            <TextBlock Text="Hi there" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Grid>

Thanks in advance
Best regards,

WPF application. Interface with Scale

$
0
0

I am working on my first WPF application. 

I need to read the data that is coming from a USB attached scale. I have the code that reads the weight.  But I am not sure how I will get it so that the Form will be up and running and constantly be reading the scale information. 

Any help is greatly appreciated. 

wpf listview background color error

$
0
0

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// MainWindow.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            lsvOrder.Items.Add(new ListViewData("1", "0001", "T1", "Timer1", "Timer4"));
            lsvOrder.Items.Add(new ListViewData("2", "0002", "T2", "Timer2", "Timer5"));
            lsvOrder.Items.Add(new ListViewData("3", "0003", "T3", "Timer3", "Timer6"));
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }
    }

    public class ListViewData
    {
        public ListViewData(string col1, string col2, string col3, string col4, string col5)
        {
            NUMBER = col1;
            ORDER = col2;
            TABLE = col3;
            ORDER_TIMER = col4;
            TABLE_TIMER = col5;
        }

        public string NUMBER { get; set; }
        public string ORDER { get; set; }
        public string TABLE { get; set; }
        public string ORDER_TIMER { get; set; }
        public string TABLE_TIMER { get; set; }
    }

    public class RowColourConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
            CultureInfo culture)
        {
            ListViewItem item = (ListViewItem)value;
            ListView lv = ItemsControl.ItemsControlFromItemContainer(item) as ListView;
            int index = lv.ItemContainerGenerator.IndexFromContainer(item);
            if (index % 2 == 0)
            {
                return Brushes.Black;//my table
            }
            return Brushes.White;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="452" Width="614"><Grid x:Name="gridHome" HorizontalAlignment="Left" Height="300" Margin="0,10,-52,-318" VerticalAlignment="Top" Width="600"><ListView x:Name="lsvOrder" Height="300" Margin="0,10,0,-10" VerticalAlignment="Top"><ListView.Resources><local:RowColourConverter x:Key="RowColourConverter"/><Style TargetType="ListViewItem"><Setter Property="Background"><Setter.Value><Binding RelativeSource="{RelativeSource Self}"
                              Converter="{StaticResource RowColourConverter}"/></Setter.Value></Setter></Style></ListView.Resources><ListView.View><GridView><GridViewColumn Header="No" Width="60"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding NUMBER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Order No" Width="120"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding ORDER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="table" Width="120" ><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding TABLE}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Order Info" Width="150"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding ORDER_TIMER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Table Info" Width="150"><GridViewColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding TABLE_TIMER}" ></TextBlock></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn></GridView></ListView.View></ListView><Button Content="Button" HorizontalAlignment="Left" Height="65" Margin="20,329,0,-94" VerticalAlignment="Top" Width="75" Click="Button_Click"/></Grid></Window>

I get theerror.

<local:RowColourConverter  <- "It is not supportedby the project." Message

What is the problem?

Please answer.

 



Visual Studio 2015 WPF XAML Editor cannot open XAML files

$
0
0

I have recently updated from Visual Studio 2015 to Visual Studio 2015 Update 2 (Professional). Everything works fine except the fact that I can't open XAML files - after clicking on any XAML file I get:


Visual Studio has encountered an unexpected error.


It looks that XamlDesignerPackage hasn't been installed. XamlEditor entry doesn't exist under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\ and it exists under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\ which may suggest that XAML Designer is not installed for this visual studio 2015.

I have tried everything:

  • 4 reinstalls
  • cleaning caches
  • removing ComponentDataCache
  • resetting settings.

In Visual Studio 2013 everything works fine. Is there a way to use XAMLEditor from VS2013? Do you have any ideas what I can do? I would be glad for any help since it prevents me from working. This is an error from ActivityLog.xml:

507 2016/04/04 13:15:58.450 Error VisualStudio SetSite failed for package [XamlDesignerPackage][Method failed with unexpected error code 50.]:{ at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext) at System.Security.AccessControl.FileSystemSecurity..ctor(Boolean isContainer, String name, AccessControlSections includeSections, Boolean isDirectory) at System.Security.AccessControl.FileSecurity..ctor(String fileName, AccessControlSections includeSections) at Microsoft.VisualStudio.DesignTools.Utility.IO.AccessHelper.IsAccessibleByAllApplicationPackages(String path) at Microsoft.VisualStudio.DesignTools.HostUtility.Utils.HostAppPackageAclService.CheckAclsOnDirectory(String directory) at Microsoft.VisualStudio.DesignTools.HostUtility.Utils.HostAppPackageAclService.ValidateOrUpdateDirectoryAcls(String directory) at Microsoft.VisualStudio.DesignTools.HostUtility.Utils.HostAppPackageAclService.ValidateOrUpdateAclsNoPrompt(IEnumerable`1 paths) at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.Initialize() at MS.Internal.Package.XamlDesignerPackage.Initialize() 
at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)} {512BE089-83EC-4CC6-8483-CF16565AE209}


80131509 Method failed with unexpected error code 50.

I have also removed both 2013 and 2015 and installed 2015 and getting the following message when running Visual Studio 2015:

Edit: I don't know how to get rid of that gray background, please remove that background from this post.


Image available in the Preview and Unavailable in the Debug (Running App) in WPF

$
0
0

Hi Folks,

I have an image in VS. I add it into the resources of my application. Moreover, it building action is setted as a Resource for the application. What I find odd is that

  • When I use 
<Image Source="pack://siteoforigin:,,,/Resources/appbar.settings.png" Height="70" Width="63" Visibility="Visible" Margin="48,0,50,0"/> 

to create the image. It does not appear when debugging the application.

  • Furthermore, If I use 
<Image Source="/GrapherV4;component/Resources/appbar.settings.png" Height="70"  Width="63" Visibility="Visible" Margin="48,0,50,0"/>

the image appears.

I wonder!!!!!!!!!!!!!!!!!

What is the difference between these two snippeds

Cheers


Many

Datagrid Text DisappearsWhen Using Arrow-Keys

$
0
0

Throughout my program I have a number of DataGrids that are used to display various amounts/types of data. If I click through the DataGridRows there is no issue whatsoever. Each DataGridCell looks something like this;



However, if I navigate using the arrow keys instead of clicking on the row, the DataGridCell now looks like this;



Has anyone experienced this behaviour before? I appreciate that I could just disable the arrow keys however this would not be best-case scenario.

Here is the XAML of just one of the DataGrids;

<DataGrid x:Name="companyDataGrid" ColumnWidth="*" IsReadOnly="true"
                          Margin="10"
                          HeadersVisibility="Column" AutoGenerateColumns="False"
                          CanUserAddRows="False" SelectionChanged="DataGridSelectionChanged"
                          IsSynchronizedWithCurrentItem="False"
                          EnableRowVirtualization="True"
                          ItemsSource="{Binding CompanyICollectionView}">


Create a custom Container in WPF with C#

$
0
0

Hi folks, 

I would like to create a custom container in WPF. It may look like the image below and should be able to have any control in its blank field. More over, I would like the expander to expand and shrink the UserControl so that only the blue strip and the expander that remain.

It may not be worth but the code is

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="38"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Expander x:Name="expander" Grid.Column="1" Grid.Row="0" Header="Expander" Margin="0,0,0,0"  Width="30"Height="36"/>
            <Border Grid.Column="0" Background="{Binding ElementName=expander, Path=Background}" Height="28"VerticalAlignment="Bottom" Margin="0,0,0,10"/>
        </Grid>
        <ContentPresenter Grid.Row="1"  />
    </Grid>

Is someone can help me?

Cheers


Many



Binding Popup position to mainwindow

$
0
0

Hello 

I am using Popup control as Menu in my WPF application

I use this control because I would like my menu is above all other controls.
it works but if I moves the main window, popup remains static.
I would like the popup also move when I moves the main window.

Here is a small example of my issue.

Here is my code 

<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication3"
        mc:Ignorable="d"
        Title="MainWindow" Height="480" Width="640"><Grid><TextBlock FontSize="18" TextWrapping="Wrap" Text="ed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. " /><Grid x:Name="cMenu" Width="250" HorizontalAlignment="Left"><Popup  Placement="Relative"    PlacementTarget="{Binding ElementName=cMenu}"     IsOpen="True" AllowsTransparency="True"  Width="{Binding ActualWidth, ElementName=cMenu}" Height="{Binding ActualHeight, ElementName=cMenu}"    ><Grid Background="#CC040404"></Grid></Popup></Grid></Grid></Window>

Thanks in advance for your help

Grid and Window Design

$
0
0

I'm new to WPF and still trying to get my feet underneath me.  I've created a simple login form, and for the life I must be doing something.  I just can't imagine it takes so much design work to get this accomplished.  I've posted my axml below.  Is there a better way to doing this, or is this just part of getting used to wpf.

<Grid Background="AliceBlue"><Grid.ColumnDefinitions><ColumnDefinition Width="200" /><ColumnDefinition Width="*" /></Grid.ColumnDefinitions><Image Grid.Column="0" Source="pack://siteoforigin:,,,/Resources/Images/Logo.png"></Image><Grid Grid.Column="1"><Grid.RowDefinitions><RowDefinition Height="50"/><RowDefinition Height="150"/><RowDefinition Height="*"/></Grid.RowDefinitions><Label Grid.Row="0" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">Please Log In</Label><Grid Grid.Row="1"><Grid.ColumnDefinitions><ColumnDefinition Width="125"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="*" /><RowDefinition Height="*" /></Grid.RowDefinitions><Label Grid.Column="0" FontSize="20" Height="35" VerticalContentAlignment="Center" Margin="0,10,2,5" HorizontalContentAlignment="Right" VerticalAlignment="Bottom" Grid.Row="0">User ID:</Label><Label Grid.Column="0" FontSize="20" Height="35" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" VerticalAlignment="Top" Grid.Row="1">Password:</Label><TextBox Grid.Column="1" Height="35" Width="170" Margin="0,10,2,5" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.Row="0"></TextBox><TextBox Grid.Column="1" Height="35" VerticalAlignment="Top" Grid.Row="1" Width="170" HorizontalAlignment="Left"></TextBox></Grid><StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"><Button Width="75" Height="40" Margin="0,0,10,0" Name="btnConfirm" Click="btnLogIn_Click"><Image Source="pack://siteoforigin:,,,/Resources/Images/Confirm.png"></Image></Button><Button Width="75" Height="40" Margin="0,0,10,0" Name="btn"><Image Source="pack://siteoforigin:,,,/Resources/Images/Cancel.png"></Image></Button></StackPanel></Grid></Grid>

WPF: how to make the row header in DataGrid show the same color as selected row highlight color?

$
0
0

Our WPF application includes DataGrid. We have define following cell style for DataGrid.

<Style x:Key="gridCellStyle2"
           TargetType="{x:Type DataGridCell}"><Style.Triggers><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsSelected" Value="False" /><Condition Property="IsReadOnly" Value="True" /></MultiTrigger.Conditions><Setter Property="Background" Value="{StaticResource GroupBackgroundColor2}" /></MultiTrigger><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsEnabled" Value="False" /><Condition Property="IsReadOnly" Value="True" /></MultiTrigger.Conditions><Setter Property="Background" Value="{StaticResource GroupBackgroundColor2}" /></MultiTrigger><Trigger Property="IsSelected" Value="True"><Setter Property="Background" Value="{StaticResource {x:Static SystemColors.HighlightBrushKey}}" /></Trigger></Style.Triggers></Style>

We also define the DataGridRowHeader style as following:

<Style x:Key="dataGridRowHeaderStyle"
           TargetType="{x:Type DataGridRowHeader}"><Setter Property="VerticalContentAlignment" Value="Center" /><Setter Property="HorizontalAlignment" Value="Center" /><Setter Property="SeparatorBrush" Value="{x:Null}" /><Setter Property="FontSize" Value="16" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type DataGridRowHeader}"><Grid><Border x:Name="rowHeaderBorder"
                                Background="{Binding Background, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                BorderBrush="{x:Null}"
                                BorderThickness="0"
                                Padding="3,0,3,0"><ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /></Border></Grid><!--<ControlTemplate.Triggers><Trigger Property="IsRowSelected"  Value="True"><Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" /></Trigger></ControlTemplate.Triggers>--></ControlTemplate></Setter.Value></Setter></Style>

As above the row header style, when click the row header to highlight a row, whole row shows the selected color and the row header will not highlight as the selected color.

We do try the "IsRowSelected" trigger section code, however, it does not work.

If we want to the row header also show the highlight row color, how do achieve that? Thx!


JaneC


Loading resources from XAML, problem with fonts

$
0
0
I am (I have to) using an XAML file as a resource from my main window.
In this simplified example, the XAML file looks like this
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="themeGrid"><Image Height="Auto" HorizontalAlignment="Left" Margin="0" Stretch="Fill" VerticalAlignment="Top" Width="Auto"><Image.Source><BitmapImage UriSource="pack://siteoforigin:,,,/Resources/image1.jpg" CacheOption="OnLoad" /></Image.Source></Image></Grid>

The file is loaded that way (the XAML file, as well as a 'image1.jpg' file, are in a 'Resources' folder along with the exe file)
Imports System.IO
Class MainWindow
    Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        loadInterface()
    End Sub
    Sub loadInterface()
        ' Load xaml file as content of the window
        Dim GridUri As String = System.AppDomain.CurrentDomain.BaseDirectory & "Resources\theme.xaml"
        Dim fs As FileStream = New FileStream(GridUri, FileMode.Open, FileAccess.Read)
        Dim sri = TryCast(System.Windows.Markup.XamlReader.Load(fs), Grid)
        Me.Content = sri
        fs.Close()
    End Sub
End Class
..and that works nicely

Now I would like to use a label whit a font file taken in the same 'Resources' folder (the font used in this example: http://www.dafont.com/fr/digital-7.font)

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="themeGrid"><Image Height="Auto" HorizontalAlignment="Left" Margin="0" Stretch="Fill" VerticalAlignment="Top" Width="Auto"><Image.Source><BitmapImage UriSource="pack://siteoforigin:,,,/Resources/image1.jpg" CacheOption="OnLoad" /></Image.Source></Image><Label FontFamily="pack://siteoforigin:,,,/Resources/#Digital-7" Content="Have a nice day!"/></Grid>

...but then the label text isn't displayed with the proper FontFamily!

What should I please do for the text of the label to be displayed using the font in the resources folder?
Thanks very much!!

Owner

$
0
0

I am calling this from the view model of a user control, the problem

I have is I need to set the owner but not sure how,

if I leave it as the default it fails? I get a Cannot set Owner property to itself.

if (companyEditVmToClose.Company.IsChanged)             {                 var result = _message.ShowYesNoDialog("Close tab?",                     "All changes will be lost, are you sure you want to close this tab?"MessageDialogResult.No);                 if (result == MessageDialogResult.No)                 {                     return;                 }             }

 public class MessageDialogService : IMessageDialogService    {        public Enums.MessageDialogResult ShowYesNoDialog(string title, string text, Enums.MessageDialogResult defaultResult = MessageDialogResult.Yes)        {            var dlg = new MessageDialog(title, text, defaultResult, MessageDialogResult.Yes, MessageDialogResult.No)            {                Owner = Application.Current.MainWindow            };            return dlg.ShowDialog();        }    }
}

if (companyEditVmToClose.Company.IsChanged)          {              var result = _message.ShowYesNoDialog("Close tab?",                  "All changes will be lost, are you sure you want to close this tab?"MessageDialogResult.No);              if (result == MessageDialogResult.No)              {                  return;              }          }          CompanyEditViewModels.Remove(companyEditVmToClose);

if (companyEditVmToClose.Company.IsChanged)          {              var result = _message.ShowYesNoDialog("Close tab?",                  "All changes will be lost, are you sure you want to close this tab?"MessageDialogResult.No);              if (result == MessageDialogResult.No)              {                  return;              }          }          CompanyEditViewModels.Remove(companyEditVmToClose);


Viewing all 18858 articles
Browse latest View live


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