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

Window Activation

$
0
0

I written a text editor application in WPF: http://edi.codeplex.com/

...and would like to implement a SingleInstance feature as in Notepad++. That is, the user should be able to start the editor more than once (with different files as parameter) and the System should 1 Activate the MainWindow,
2 display the editor for editing (if started for the second time) and
3 the user should be able to start editing by typing on the keyboard

I found a way to implement the communication between the first and second instance and I even got close to activation part 3. Here however is a small problem, which is, that the MainWindow is only blinking in the taskbar and the editor is showing the current file with blinking cursor (but the keyboard focus seems to be missing (because the window title bar still has the deactivated color and typing on the keyboard does not end up in the editor).

I have tried all sorts of different implementations such as 'Keyboard.Focus(Mainwindow)' and so forth but I am somehow not getting there.

Can anyone help me with this advanced focus problem? The general app code itself should be OK since I can ALT+TAB and CTRL+TAB with the expected results... Here is the code that I am using to activate the second instance - what am I doing wrong when activating the existing MainWindow in the App.cs class?

dispatcher.BeginInvoke(
          new Action(delegate
          {
            var mainWindow = Current.MainWindow as MainWindow;

            if (mainWindow != null)
            {
              if (mainWindow.IsVisible == false)
                mainWindow.Show();

              if (mainWindow.WindowState == WindowState.Minimized)
                mainWindow.WindowState = WindowState.Normal;

              mainWindow.Topmost = true;
              mainWindow.Show();

              Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action)delegate
              {
                mainWindow.Activate();
                mainWindow.Topmost = false;
              });
            }


MVVM WPF Datagrid SelectedValue bind by view model ?

$
0
0
Anyone knows how to change the SelectedValue of the datagrid by ViewModel.If we change View then It will fire VM but not vise versa.

root element is not valid for navigation

$
0
0
Good Day i have a Window in WPF defined like this 

 
<Window x:Class="RVI_Education.Gavigator"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="Gavigator" Height="673.2" Width="1304.4">    <Frame Name="FrameWithinGrid" >    </Frame></Window> 



and im using it as a start up in my app.xaml

 <Application x:Class="RVI_Education.App"             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             StartupUri="Gavigator.xaml">    <Application.Resources>             </Application.Resources></Application>  



and on Window loaded event i navigate to another Window 

like this 

 
 
  public Gavigator()        {            InitializeComponent();            Loaded += Gavigator_Loaded;                   }        void Gavigator_Loaded(object sender, RoutedEventArgs e)        {           FrameWithinGrid.Navigate(new System.Uri("Splash.xaml",UriKind.RelativeOrAbsolute));        } 


 
when i load the Project i get an Error 
 
 
 RVI_Education.Splash' root element is not valid for navigation. 

Vuyiswa Maseko

How to deploy localdb database with WPF app

$
0
0

I have created a WPF app that uses a SQL database via the (localdb)\v11.0. Firstly I created the database very easily in VS2012 Pro SP1. Then using Entity Framework option 'database first' to create the classes. Now the app works but I need to deploy it to others. The database needs to run on each person's machine as it will always be local to each person's pc.

How should I go about with the deployment (without creating installers)?

Currently my connection string in app.config looks something like this:

<connectionStrings><add name="DatabaseContext" connectionString="metadata=res://*/src.DatabaseModel.csdl|res://*/src.DatabaseModel.ssdl|res://*/src.DatabaseModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\v11.0;initial catalog=DatabaseFirst;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

Aero2 theme with Visual Studio 2010 doesn't work

$
0
0

My WPF control library uses multiple theme XAML files to adapt to the different UI themes of previous Windows versions. Besides Generic.xaml it contains Classic.xaml, Luna.NormalColor.xaml, other Luna colours, Aero.NormalColor.xaml and now I've added Aero2.NormalColor.xaml to also support Windows 8. At least this was the name I've found on the internet. This solution targets the .NET 4.0 Client Profile framework. But here's the problem:

When I compile it with Visual Studio 2010 SP1 on Windows 7, my main development environment, and copy the binary over to a Windows 8 machine, the app is using the Generic.xaml style.

Only when I copy the source code over to the Windows 8 machine and re-compile it with Visual Studio 2012 Update 1, then the Aero2 theme is used and my app control looks more like a citizen of Windows 8.

Is this a known problem of WPF or VS2010? There's hardly any information about theme-specific styles for WPF and Windows 8 available.

Difference between two datagrid values and display the result in a new row

$
0
0

I have a datagrid that displays a table from a database vertically as follows : 

  Scores1     | 75
  Scores2     | 100
  Difference  | ?

      
I have to added a new row called Difference which should display the difference between theScores1 row value  & the Scores2 row value.

(P.S : No negative values from the difference)

How to achieve this in WPF?


Beauty is within what you see & feel ! - Indhira

Create dynamic DataGrid with style and properties from an existing datagrid

$
0
0

Hi, in .NET Framework 4.0, C# WPF form, on my UserControl Grid I defined a datagrid 'myDataGrid' with style and some properties.
I did not put any code in the UC Resources block
The 'myDataGrid' is bound to a datatable at runtime.

Now, at runtime I have to generate additional dynamic datagrids that have the same style and properties like the 'myDataGrid'. I can generate dynamic datagrids and bound them to data but their style/properties are not like 'myDatagrid'

<DataGrid Grid.Row="0" Name="myDataGrid" SelectionUnit="CellOrRowHeader" ItemsSource="{Binding}"><DataGrid.RowStyle><Style TargetType="{x:Type DataGridRow}"><Style.Triggers><DataTrigger Binding="{Binding STATUS}" Value="ACTIVE"><Setter Property="Foreground" Value="Green"/></DataTrigger></Style.Triggers></Style></DataGrid.RowStyle></DataGrid>
Thanks,

-sri


sri

WPF DataGrid drag-fill (auto-fill) functionality - possible?

$
0
0

I would like to emulate the auto-fill / drag-fill functionality in Excel, i.e. when you select one or more cells in a row then a border appears around them, with a small cross in its bottom-right corner. Dragging this cross down over subsequent rows results in the values in the selected cells being copied into the cells of those rows.

I suspect this is asking too much of the DataGrid, but would be interested to hear ideas as to how it may be achieved...



Modal dialog opened from view model gets separated from main window on switching to other application

$
0
0

I have a Modal dialog in my application. I am opening the dialog from a command in view model using window.ShowDialog() .

The problem is that when we switch to other opened application and then clicking on our app in taskbar hides the modal dialog. I have figured out that the problem is due to Window ownership.

i can't assign the owner to modal dialog from view model. Please help.

How can I change label content at runtime on a window with a storyboard running? (.NET 3.5)

$
0
0

My Main Window opens a dialog that displays a progress spinner storyboard and should update the content of the labels as the program does some work, but I can't seem to change the label content on that dialog during runtime.

I'm familiar with background workers and the dispatcher, I've been able to update controls before, i.e.:

                main.label_Connected.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                (ThreadStart)delegate { main.label_Connected.Content = "Not Connected"; }
            );

but it doesn't work in this case.  Is there something specific to updating controls when there is a storyboard running?

Object reference not set to an instance of an object

$
0
0
 
在用wpf的时候发现个奇怪的问题:在嵌套的控件里面,如果有控件调用了事件处理程序和使用了ContentTemplateSelector时,程序就会提示:Object reference not set to an instance of an object.。删掉其中任何一个就不会出错 
When in use wpf found a strange problem: nested controls inside, if the control calls the event handler and use the ContentTemplateSelector, the program will prompt: Object reference not set to an instance of an object.. Delete any of them will not go wrong



源码如下,删除下面的Click或者ContentTemplateSelector就正常,同时存在就会报错: 
 Source as follows, delete the following Click or ContentTemplateSelector to normal, while there will be error


<Window x:Class="TestApp.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:control="clr-namespace:TestApp"       Title="MainWindow" Height="350" Width="525">    <Window.Resources>        <control:MyTemplateSelector x:Key="bbb"></control:MyTemplateSelector>    </Window.Resources>   <ItemsControl   ItemsSource="{Binding}">        <ItemsControl.ItemTemplate>            <DataTemplate >                <ItemsControl ItemsSource="{Binding}"   DataContext="{Binding Path=ItemsSource, RelativeSource={RelativeSource AncestorType=ItemsControl,Mode=FindAncestor}}">                    <ItemsControl.ItemTemplate>                       <DataTemplate >                            <WrapPanel >                               <Button Cursor="Hand"    Content="bbbbbbbb"  Height="23"     Width="75"   Click="ShowContextMenu" >                               </Button>                                <ContentControl    Content="aa" ContentTemplateSelector="{StaticResource bbb}" />                            </WrapPanel>                        </DataTemplate>                   </ItemsControl.ItemTemplate>                </ItemsControl>            </DataTemplate>        </ItemsControl.ItemTemplate>   </ItemsControl></Window>
<Window x:Class="TestApp.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:control="clr-namespace:TestApp"       Title="MainWindow" Height="350" Width="525">    <Window.Resources>        <control:MyTemplateSelector x:Key="bbb"></control:MyTemplateSelector>    </Window.Resources>   <ItemsControl   ItemsSource="{Binding}">        <ItemsControl.ItemTemplate>            <DataTemplate >                <ItemsControl ItemsSource="{Binding}"   DataContext="{Binding Path=ItemsSource, RelativeSource={RelativeSource AncestorType=ItemsControl,Mode=FindAncestor}}">                    <ItemsControl.ItemTemplate>                       <DataTemplate >                            <WrapPanel >                               <Button Cursor="Hand"    Content="bbbbbbbb"  Height="23"     Width="75"   Click="ShowContextMenu" >                               </Button>                                <ContentControl    Content="aa" ContentTemplateSelector="{StaticResource bbb}" />                            </WrapPanel>                        </DataTemplate>                   </ItemsControl.ItemTemplate>                </ItemsControl>            </DataTemplate>        </ItemsControl.ItemTemplate>   </ItemsControl></Window>

 
cs源码:

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
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 TestApp
{
    /// <summary>

    /// Interaction logic for MainWindow.xaml

 

    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            List<TestClass> data = new List<TestClass>();
            data.Add(new TestClass() { date = "aaaa", name = "aa1", username ="姓名"});
            data.Add(new TestClass() { date = "bbb", name = "bbb", username = "姓名1" });
            this.DataContext = data;
        }
        private void ShowContextMenu(object sender, RoutedEventArgs e)
        {
        }
    }
    public class TestClass:System.ComponentModel.INotifyPropertyChanged
    {
        public string name
        {
            get;
            set;

        }
        public string date
        {
            get;
            set;
        }
        public string username
        {
            get;
            set;
        }
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    }
    public class MyTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            return null;
        }
    }

LINQ JOIN QUERY NOT BINDING

$
0
0

Hi,

I want to bind few values to my datagrid (WPF Control)..through linq, when i tred with Join queries it through me the error as follows.

A TwoWay or OneWayToSource binding cannot work on the read-only property 'empname' of type '<>f__AnonymousType0`4[System.String,System.String,System.String,System.String]'.

infos--Table1

infoplus--Table2

             

var q1 = from tt in linqtosql.infos
                          join cc in linqtosql.infoplus
                          on Convert.ToInt16(tt.empcity) equals cc.cityid
                          select new { tt.empname, cc.cityname, tt.emprole, tt.states };

    dgview.DataContext = q1;

XAML CODING:

<DG:DataGrid ItemsSource="{Binding}"  AutoGenerateColumns="False" Name="dgview">
                    <DG:DataGrid.Columns>
                        <DG:DataGridTextColumn  Binding="{Binding empname}"  Header="NAME" Width="100">
                                
                        </DG:DataGridTextColumn>
                        <DG:DataGridTextColumn Binding="{Binding emprole}" Header="ROLE" Width="100">
                            
                        </DG:DataGridTextColumn>
                        <DG:DataGridTextColumn Binding="{Binding cityname}" Header="CITY" Width="100">
                            
                        </DG:DataGridTextColumn>
                        <DG:DataGridTextColumn Binding="{Binding states}" Header="STATE" Width="100">
                            
                        </DG:DataGridTextColumn>
                    </DG:DataGrid.Columns>
                </DG:DataGrid>


Thanks SABARINATHAN87

TabControl ContentTemplate binding problem

$
0
0

Hello,

I am writing a testapplication in C# using WPF, but got a problem with binding the tabcontrol.

My scenario is as follows:

I have created an custom object called TestCategory this object has a collection of TesttableParts (TesttablesCollection). Now I want to show a tab for every TestCategory, for every testtablepart in the collection of the TestCatecory there should be a string with a result displayed on the tab. I created a ItemTemplate for the string and the result of the TesttablePart. I got this working without a problem.

But now I want to change the ItemTemplate of the TesttablePart with an other one based on a property (ResultPresentationTypeEnum) of my TesttablePart, I have writen the below code but the binding does not work correctly.

<TabControl.ContentTemplate><DataTemplate><ItemsControl ItemsSource="{Binding TesttablesCollection}" Margin="20"><ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel Orientation="Vertical" /></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.Style><Style TargetType="ItemsControl"><Style.Triggers><DataTrigger Binding="{Binding Path=ResultPresentationTypeEnum}"><DataTrigger.Value><etafResults:ResultPresentationType>BOOL</etafResults:ResultPresentationType></DataTrigger.Value><Setter Property="ItemTemplate" Value="{StaticResource BoolTestPartTemplate}"/></DataTrigger><DataTrigger Binding="{Binding Path=ResultPresentationTypeEnum}"><DataTrigger.Value><etafResults:ResultPresentationType>VALUE</etafResults:ResultPresentationType></DataTrigger.Value><Setter Property="ItemTemplate" Value="{StaticResource ValueTestPartTemplate}"/></DataTrigger></Style.Triggers></Style></ItemsControl.Style></ItemsControl></DataTemplate></TabControl.ContentTemplate>

This template gives me a binding error stating that the ResulPresentationTypeEnum property in the DataTriggers, cant be found on the TestCategory object. But the property should be bound to the particular instance in the TesttablesCollection (the ItemsSource), this is a TesttablePart instance.

How can I change the bindings so that it point to the TesttablePart instance of the TesttablesCollection rather than the parent TestCategory object to which the collection belongs.

Any help would be greatly appreciated.

Marcel



Error loading XAML file in designer

$
0
0

When I open up my XAML file from a WPF 4.0 application in the VS 2010 designer, I get this error message:

Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
   bei Microsoft.Expression.Platform.WPF.InstanceBuilders.DocumentNodeObjectReader.get_Value()
   bei System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   bei System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
   bei System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   bei System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, Boolean skipJournaledProperties, Uri baseUri)
   bei System.Windows.Markup.XamlReader.Load(XamlReader xamlReader, ParserContext parserContext)
   bei System.Windows.Markup.XamlReader.Load(XamlReader reader)
   bei Microsoft.Expression.Platform.WPF.InstanceBuilders.FrameworkTemplateInstanceBuilder.InstantiateTemplate(IDocumentRoot xamlDocument, TemplateSerializerContext context)
   bei Microsoft.Expression.DesignModel.InstanceBuilders.FrameworkTemplateInstanceBuilderBase`7.Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
   bei Microsoft.Expression.DesignModel.Core.ViewNodeManager.Instantiate(ViewNode viewNode)

I've tried to analyse it by the instructions in the help, but debugging the VS process didn't work and I cannot determine the designer mode in my markup extension class. Also this exception message is not helpful. Where can I go on searching now?

I've tried to create a small test case application containing only the offending code, but everything works fine there. I could not create a working testcase yet to demonstrate the error.

Oh, and everything works perfectly at runtime, it's just the designer that is broken.

Creating new WPF window within a MAF Add-In

$
0
0

Hello, 

I have a WPF application, which hosts a series of isolated plugins as documentedhere.  Everything seems to be working very well, only recently I tried to get one of my Add-Ins to create a child window (nothing particularly notable about the code!):

            Window w = new Window();
            w.Width = 100;
            w.Height = 100;
            w.Show();

When I subsequently shut this window down, the entire UI for the plug-in disappears!  I don't seem to get any exceptions that I can hook in to (I'm hooking in to the unhandled exception events on the AppDomain and Dispatcher).

Any suggestions or advice gratefully received!



OpenClipboard error with Windows 8

$
0
0

I have an application written in WPF that requires the user to fill in some textboxes in a uniform grid.  When all of the cells have been filled in and validated, the code calls the Clipboard.Clear() method and then copies the information in the cells to the clipboard.  This application worked just fine on both WindowsXP and Windows 7.  However, we recently upgraded to Windows 8, and it fails when copying to the clipboard.  The line in question is the following:

Clipboard.SetData(DataFormats.Text, cellContents.ToString());

The error is the following:

     OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))

I have tried adding a delay in the code, but that only works if I step through the code.  Otherwise, I cannot seem to make the delay long enough. 

Is there any reason why this would work differently on the Windows 8 desktop versus Windows 7 and WindowsXP?  Is there anything else I should be doing to get this to work in Windows 8?

Thanks in advance for your help! 


Christine A. Piffat

getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound."

$
0
0
 

Hi all,
 
I'm working on a WPF solution where I have to populate a combobox depending on the selected item of another combobox. But I get an error.
 
The XAML code is:
 
<Window xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
        x:Class="ICP.Reporting.WPFReportViewer.Windows.Report_Script_Resultaten"
        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"
        mc:Ignorable="d"
        xmlns:navigation="clr-namespace:Infragistics.Silverlight.SampleBrowser.Framework.Controls;assembly=Infragistics.Silverlight.SampleBrowser.Framework"
        xmlns:ig="http://schemas.infragistics.com/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:uri="clr-namespace:ICP.Reporting.WPFReportViewer.Resources.ReportUri"
        xmlns:res="clr-namespace:ICP.Reporting.WPFReportViewer.Resources.Pages"
        d:DesignHeight="500" d:DesignWidth="567" SizeToContent="WidthAndHeight"
        Title="Report Scripts Resultaten"
        WindowStartupLocation="CenterScreen" Icon="/ICP.Reporting.WPFReportViewer;component/Images/Report_New.ico">
 
    <Window.Resources>
        <uri:ReportLibraryUri x:Key="ReportLibraryUri" />
        <res:ParametersStrings x:Key="ParametersStrings" />       
    </Window.Resources>
 
    <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"/>          
        </Grid.RowDefinitions>
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
 
        <StackPanel Name="stackPanelParameters" Orientation="Vertical" VerticalAlignment="Top" Height="Auto" HorizontalAlignment="Center" Width="170" Grid.Row="0" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="1" Margin="10,5">
           
            <GroupBox Name="groupBoxBeginEindDatum" Header="Kies begin- en einddatum" Height="Auto" Width="Auto" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <StackPanel Name="stackPanelBeginEindDatum" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Width="Auto" >
                    <!-- <Label Height="28" Content="{Binding Source={StaticResource ParametersStrings}, Path=Binding_StartDate}" Margin="15,10,5,10" Width="77"/> -->
                    <Label Height="20" Content="Begindatum:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <!--<DatePicker Name="datePickerBeginDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="{x:Static sys:DateTime.Now}" Text="" SelectedDate="{x:Static sys:DateTime.Now}" Margin="5,0" Padding="2" />-->
                    <DatePicker Name="datePickerBeginDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="01-01-2012" Text="" SelectedDate="01-01-2012" Margin="5,0" Padding="2" />
                    <!-- <Label Height="28" Content="{Binding Source={StaticResource ParametersStrings}, Path=Binding_EndDate}" Margin="15,10,5,10" Width="70"/> -->
                    <Label Height="20" Content="Einddatum:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <!--<DatePicker Name="datePickerEindDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="{x:Static sys:DateTime.Now}" Text="" SelectedDate="{x:Static sys:DateTime.Now}" Margin="5,0" Padding="2" />-->
                    <DatePicker Name="datePickerEindDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="12-31-2012" Text="" SelectedDate="12-31-2012" Margin="5,0" Padding="2" />
                </StackPanel>
            </GroupBox>
                       
            <GroupBox Name="groupBoxAuthoriteitScript" Header="En authoriteit en script" Height="Auto" Width="Auto" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <StackPanel Name="stackPanelAuthoriteitScript" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Width="Auto">
                    <Label Height="20" Content="Authoriteit:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <ComboBox Height="25" Name="comboBoxAuthoriteit" Margin="5,0" Padding="2" SelectedIndex="-1" ItemsSource="{Binding}" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" SelectionChanged="comboBoxAuthoriteit_SelectionChanged" />
                    <Label Height="20" Content="Script:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <ComboBox Height="25" Name="comboBoxScript" Margin="5,0" Padding="2" SelectedIndex="-1" ItemsSource="{Binding}" DisplayMemberPath="Name" />
                </StackPanel>
            </GroupBox>
 
            <GroupBox Name="groupBoxRapport" Header="Rapport" Height="Auto" Width="Auto" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <StackPanel Name="stackPanelRapport" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Width="Auto">
                    <!-- <Button Content="{Binding Source={StaticResource ParametersStrings}, Path=Refresh}" Margin="20,5,10,5" Click="Button_Refresh_Click" Height="23" Width="61" /> -->
                    <Button Content="Genereer rapport" Margin="5" Click="Button_Refresh_Click" Height="23" Width="100" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </StackPanel>
            </GroupBox>
           
        </StackPanel>
 
        <ig:XamReportViewer HorizontalAlignment="Center" Name="xamReportViewer1" VerticalAlignment="Bottom" PageFit="Width" UseLayoutRounding="True" MinWidth="380" MinHeight="445" PageMargin="0" AutoRender="True" Grid.Row="0" Grid.Column="1" Margin="0">
            <ig:XamReportViewer.RenderSettings>
                <ig:ClientRenderSettings DefinitionUri="/ICP.Reporting.ReportingClassLibrary;component/ReportDesigns/Report_Scripts_Resultaten.igr" />
            </ig:XamReportViewer.RenderSettings>
 
            <!-- Binding parameters -->
            <ig:XamReportViewer.Parameters>
                <ig:Parameter ParameterName="beginDatum" ParameterValue="{Binding ElementName=datePickerBeginDatum, Path=SelectedDate}"/>
                <ig:Parameter ParameterName="eindDatum" ParameterValue="{Binding ElementName=datePickerEindDatum, Path=SelectedDate}"/>
                <!--<ig:Parameter ParameterName="Maand" ParameterValue="{Binding ElementName=comboBoxMaand, Path=SelectedValue}"/>
                <ig:Parameter ParameterName="Jaar" ParameterValue="{Binding ElementName=comboBoxJaar, Path=SelectedValue}"/>
                <ig:Parameter ParameterName="Authoriteit" ParameterValue="{Binding ElementName=comboBoxAuthoriteit, Path=SelectedItem}"/>
                <ig:Parameter ParameterName="Script" ParameterValue="{Binding ElementName=comboBoxScript, Path=SelectedItem}"/>-->
            </ig:XamReportViewer.Parameters>
 
        </ig:XamReportViewer>
    </Grid>
   
</Window>
 
The code behind is:
 
using ICP.Reporting.ReportingClassLibrary;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Infragistics.Controls.Reports;
 
namespace ICP.Reporting.WPFReportViewer.Windows
{
    /// <summary>
    /// Interaction logic for Report_Script_Resultaten.xaml
    /// </summary>
    public partial class Report_Script_Resultaten : Window
    {
        public Report_Script_Resultaten()
        {
            InitializeComponent();
 
            CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);
            ci.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
            ci.DateTimeFormat.DateSeparator = "-";
            Thread.CurrentThread.CurrentCulture = ci;
 
            //datePickerBeginDatum.DisplayDate = DateTime.Today.AddDays(-7);
            //datePickerBeginDatum.SelectedDate = DateTime.Today.AddDays(-7);
            //datePickerEindDatum.DisplayDate = DateTime.Today.AddDays(-1);           
            //datePickerEindDatum.SelectedDate = DateTime.Today.AddDays(-1);
 
            BindComboBoxAuthoriteit(comboBoxAuthoriteit);           
        }
 
        private void Button_Refresh_Click(object sender, RoutedEventArgs e)
        {
            this.xamReportViewer1.Refresh();
        }
 
        public void BindComboBoxAuthoriteit(ComboBox comboBoxName)
        {
            string strConnectionAuthoriteit = ConfigurationManager.ConnectionStrings["ICP.Reporting.ReportingClassLibrary.Properties.Settings.sqlDS_Authorities"].ConnectionString;
            SqlConnection connectionAuthoriteit = new SqlConnection(strConnectionAuthoriteit);
            SqlDataAdapter daAuthoriteit = new SqlDataAdapter("SELECT Authority_ID, Description FROM Authorities ORDER BY Description", connectionAuthoriteit);
            DataSet dsAuthoriteit = new DataSet();
            daAuthoriteit.Fill(dsAuthoriteit, "Authorities");
            comboBoxName.ItemsSource = dsAuthoriteit.Tables[0].DefaultView;
            comboBoxName.DisplayMemberPath = dsAuthoriteit.Tables[0].Columns["Description"].ToString();
            comboBoxName.SelectedValuePath = dsAuthoriteit.Tables[0].Columns["Authority_ID"].ToString();
        }
 
        private void comboBoxAuthoriteit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxAuthoriteit.SelectedIndex > -1)
            {
                BindComboBoxScript(comboBoxScript);
            }
        }
 
        public void BindComboBoxScript(ComboBox comboBoxName)
        {
            string strqryScript = string.Format("SELECT Questionnaire_Id, Questionnaire_Name FROM Questionnaires WHERE (Authority_ID = {0}) ORDER BY Questionnaire_Name", comboBoxAuthoriteit.SelectedItem);
 
            string strConnectionScript = ConfigurationManager.ConnectionStrings["ICP.Reporting.ReportingClassLibrary.Properties.Settings.sqlDS_Scripts"].ConnectionString;
            SqlConnection connectionScript = new SqlConnection(strConnectionScript);           
            SqlDataAdapter daScript = new SqlDataAdapter(strqryScript, connectionScript);
            DataSet dsScript = new DataSet();
            //DataTable dtScript = new DataTable();
            daScript.Fill(dsScript, "Questionnaires");
 
            comboBoxName.ItemsSource = dsScript.Tables[0].DefaultView;
            comboBoxName.DisplayMemberPath = dsScript.Tables[0].Columns["Questionnaire_Name"].ToString();
            comboBoxName.SelectedValuePath = dsScript.Tables[0].Columns["Questionnaire_Id"].ToString();
 
            //foreach (DataRow drScript in dsScript.Tables)
            //{
            //comboBoxScript.Items.Add(drScript[0].ToString());
 
            //}
        }
    }   
}

When I run the solution I get the sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound."
on the following line:
 
daScript.Fill(dsScript, "Questionnaires");
 
Can someone tell me where I'm going wrong and what I have to correct?
 
Thank you very much for your help.
 
Greetings,
 
Geert De Vylder

UserControl XAML Not Recognizing Code-Behind Class Name

$
0
0

I have developed various UserControls in a WPF solution called CustomControls.  Once developed, I can copy the 2 xaml files for a control into a new solution ad use it there (or compile into a library, which I'm not presently doing).

Now I'm having a strange problem, and can't figure it out.  Here is partial XAML and code-behind for one of the custom controls which is working just fine:

<UserControl x:Class="RonM.CustomCheckBox" x:Name="ccb"
             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" mc:Ignorable="d" 
             MinHeight="40" MinWidth="20" Height="100" Width="50"><UserControl.Resources>
Namespace RonM

    Public Class CustomCheckBox
        Inherits UserControl
        Implements INotifyPropertyChanged

        Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
        Private Sub NotifyPropertyChanged(ByVal info As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
        End Sub

        Public Sub New()

            ' This call is required by the designer.
            InitializeComponent()

Now, I'm trying to add a new UserControl called CustomScrollbar.  so I right-click on the solution, choose Add, select WPF and UserControl, give it a name, then click OK.  Now I have CustomScrollbar.xaml and CustomScrollbar.xaml.vb in my project.. Here are the file contents so far:

<UserControl x:Class="RonM:CustomScrollbar"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"><Grid></Grid></UserControl>
Namespace RonM

    Public Class CustomScrollbar

    End Class
End Namespace

So the problem is, when I try to build the solution I get this error:
x:Class="RonM:CustomScrollbar" is not valid. 'RonM:CustomScrollbar' is not a valid class name. Line 1 Position 14.

If I remove the "RonM:" from the first line of the XAML file, it builds ok, but then I end up with 2 different user controls in my project, one with and one without namespace in the user control name in the toolbox.  If I try to insert the one with the namespace into my MainWindow, it is empty.  If I insert the one WITHOUT the namespace into my MainWindow, it seems to be ok.

So what am I doing wrong?  The other 3 UserControls work just fine with a namespace declaration.  It seems like I should be able to add a new one using the same syntax, right?

It's probably something very simple, but I can't see it.

Thanks...


Ron Mittelman

How to create a verified click once install certificate

$
0
0

I created my own, but it says Unknown publisher and gives the warning message.  I think this is as expected because I need to get a certificate from Verisign or someone like that.  So my question is, if I use my self generated one for say 1 year and then I buy a real one from Verisign, what will the user have to do when I change to a real certificate?  Will the user have to uninstall the wpf program with the old cert and then re-install?  I'm just wondering if I can go with the one I created for a while until enough people complain, or should I just get it over with verify it.

Also, for windows 8, I get a 'Windows protected your PC' thing pop up when I try to use my own cert.  I have to click more info, and run anyway to install it.  Seems like I'll have to get a real cert to make that go away.

Also on the renewals, it's only for up to 3 years.  If I renew after 3 years, will the customer have to un-install and re-install for updates in WPF.  I think in Silverlight OOB, renewals won't work.  I'm guessing for WPF it will.  I just don't want interuptions.  For the cert that I created, I put 99 years, so I don't have to deal with that.  Anyone have experience with this?

So the real certificate I would want, would be the one below?  Can I use this same one for all my silverlight lob apps too? How many WPF apps could I use this on?  Or do I need to get a different cert for every program?  Also, some of my click once installs will be internal with the same domain.  I install on various customers servers.  Then I also want the WPF click once hosted on an external site for other customers.

Code Signing Certificates for Microsoft Authenticode

Digitally sign 32-bit or 64-bit user-mode (.exe, .cab, .dll, .ocx, .msi, .xpi, and .xap files) and kernel-mode software. Provider for Microsoft Windows Logo programs.


dan


WPF Tab Control destorying Child Control state.

$
0
0

I am having an issue with the WPF tab control destroying the state of the child control.  The usercontrols placed in tabs are unloaded and loaded everytime i switch between tabs, to create slow lag in the application.

I have research a number of solutions, most of which are hacks or toolkits i would rather not integrate.

Is there an up to date, current solution that someone could recommend? Thanks

<TabControl IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Workspaces}"
                        ItemTemplate="{StaticResource tabItem_Main}"
                        ItemContainerStyle="{StaticResource TabItemSummaryStyle}"
                        Height="1016">
                <TabControl.Template>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <StackPanel>
                            <ScrollViewer
                                Style="{StaticResource TabstripScrollViewer}"
                                HorizontalScrollBarVisibility="Visible"
                                VerticalScrollBarVisibility="Hidden"
                                Margin="0,0,320,0"
                                Background="#373737"
                              >
                                <StackPanel Background="#212121" Orientation="Horizontal" IsItemsHost="True" Margin="0,0" />
                            </ScrollViewer>
        
                            <ContentPresenter ContentSource="SelectedContent" Margin="0,10,0,0" />
                        </StackPanel>
                    </ControlTemplate>
                </TabControl.Template>
            </TabControl>

Viewing all 18858 articles
Browse latest View live


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