Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
A

ausadmin

@ausadmin
About
Posts
18
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • ReportViewer does not export PDF for wingdings fonts
    A ausadmin

    I have worked around this problem by using the characters 0080 and 0079 from the Wingdings 2 font. I think because these codes are below 127 they do get converted correctly in the pdf. I have posted this as an issue at https://connect.microsoft.com/SQLServer/feedback/details/618435/reportviewer-does-not-export-pdf-correctly-for-wingdings-fonts. Tim

    WPF help csharp question sql-server wpf

  • ReportViewer does not export PDF for wingdings fonts
    A ausadmin

    Paul, Thanks for your comments, and sorry for the slow follow up. The connect posting was from 5/6/2009 and I thought the release had now happened (the post was from some 18 months ago). I have now installed the ReportViewer 2010 Redistributable (v10.0 of ReportViewer), however this did not resolve the issue. Now, instead of the tick and cross turning into a dot, they turn into an empty small box. As I have these characters contained in multiple reports, I did not want to have to change them. Thanks for any further help. Regards, Tim

    WPF help csharp question sql-server wpf

  • ReportViewer does not export PDF for wingdings fonts
    A ausadmin

    I hope I am posting this in the correct forum - although it concerns ssrs, I think it is more a winforms / wpf question. We have a wpf application using the winforms reportviewer. This report shows a pass / fail status and I am using wingdings font with chr(0252) to display a tick and chr(0251) to display a cross. This works really well in the report and for sending to a printer, but when exported to pdf both the characters turn info small dots - not really acceptable for our users. I have seen multiple other posts about this issue as a known problem, there this is a post on Microsoft connect [^] that indicates it is fixed (on 5/6/2009). I am wondering if I am missing something obvious on how to obtain a more recent version of ReportViewer that includes a fix? Is anyone else aware of this issue or have a resolution? As this is used in quite a few different reports, I would much prefer to fix the issue, than change all the reports to use different characters or fonts. Thanks, Tim

    WPF help csharp question sql-server wpf

  • WPF OpenFileDialog and FolderBrowserDialog
    A ausadmin

    I've only just been able to get back to this question - sorry for the long delay in responding. I guess it looks like this is a complex issue - I'll keep wrapping the System.Windows.Forms controls for the time being, and look out for further developments on this question. Hopefully Microsoft might build something into a future version... Thanks, Tim

    WPF wpf csharp c++ question

  • WPF OpenFileDialog and FolderBrowserDialog
    A ausadmin

    I am wondering if anyone can point me to some code (or DLL) to build a native OpenFileDialog and FolderBrowserDialog in wpf / xaml, rather than using the System.Windows.Forms controls? We have now replaced the Forms MessageBox with a native WPF taskdialog, which looks much better and behaves more consistently. I would like to do the same for OpenFileDialog and FolderBrowserDialog. Thanks, Tim

    WPF wpf csharp c++ question

  • Reference to parent collection
    A ausadmin

    Another alternative I have discovered is to use a shared member property of a Helper object to hold the collection that needs to be searched. I can define this as follows:

    Public Class ATBusinessInfoHelper

    Private Shared \_userContainer As AUSObservableCollection(Of ATUser)
    
    Public Shared Property UserContainer() As AUSObservableCollection(Of ATUser)
        Get
            If \_userContainer Is Nothing Then
                Throw New AUSException("UserContainer has not been defined")
            Else
                Return \_userContainer
            End If
        End Get
        Set(ByVal value As AUSObservableCollection(Of ATUser))
            \_userContainer = value
        End Set
    End Property
    

    End Class

    Then in the IDataErrorInfo validation logic, I can step through ATBusinessInfoHelper.UserContainer to see if there is a conflict with an existing name. Would this be a valid approach to take? Thanks for any advice, Tim

    WPF wpf question csharp help lounge

  • Reference to parent collection
    A ausadmin

    Pete, Thanks for the suggestion of using a ViewModel. I am a big fan of using ViewModel and have made extensive use of this pattern in our project (where it fits). I found your article "Action based ViewModel and Model validation." and Josh Smith's article "Using a ViewModel to Provide Meaningful Validation Error Messages" on this approach (I assume that is what you meant), and have now modified the project accordingly. So the original class was ATUser and I defined a new UserViewModel class which wraps ATUser. I have been able to achieve the validation (and it works nicely), however I am still not sure I am following good programming practise (really my original question), because I found it essential to pass a reference to the ObservableCollection (container collection), into each UserViewModel member, so the member could find out if the user name had already been used. So a snippet of UserViewModel is

    Public Class UserViewModel
    Implements INotifyPropertyChanged
    Implements IDataErrorInfo

    Private \_user As ATUser
    Private \_containerCollection As AUSObservableCollection(Of UserViewModel)
    
    Public Sub New(ByRef User As ATUser, \_
                   ByRef ContainerCollection As AUSObservableCollection(Of UserViewModel))
        \_user = User
        \_containerCollection = ContainerCollection
        \_username = \_user.Username
    End Sub
    
    'lines removed
    Default Public ReadOnly Property Item(ByVal propertyName As String) As String Implements IDataErrorInfo.Item
        Get
            Select Case propertyName
                Case "Username"
                'logic to determine if Username is valid, which involves searching through \_containerCollection 
            End Select
        End Get
    End Property
    

    End Class

    So I believe I have achieved the goals of using the ViewModel, which include improved control over Data Validation. However I'm not sure I addressed my original concern - which is holding a reference to the containing collection within the member object itself.... Could you comment on whether I have missed the point / whether there is a more acceptable way to solve this / whether the reference to the containing collection is OK? Just to restate, in order for a UserViewModel to validate the Username property, it needs to access the containing collection, in order to see if the name has already been used. From the Data Validation point of view, I could have achieved the same by implementing IDataErrorInfo on the ATUser class, and simpl

    WPF wpf question csharp help lounge

  • Reference to parent collection
    A ausadmin

    Pete, Thank you for your reply. I have read the article you refer to ("The Observable Dictionary Sample" - correct?), however I am not clear on how this might solve the problem. I need to explain a bit more about the scenario. We have a WPF DataGrid bound to our ObservableCollection - this works really well. I am now trying to handle validation as a user makes changes. Where the valiadtion can be based solely on the content of the member object (ie the data in the row, e.g. ensure an age is between 5 and 50) - no problem, use the ValidationRule approach as is well documented. What I am having trouble with is the scenario where a value must be checked against all others in the ObservableCollection - I don't know of any way to make the ValidationRule class know about the parent collection. So I think this problem will exist, whether we are using ObservableCollection or ObservableDictionary. Please correct me if I have misunderstood your post. Maybe I am missing something, on how we can pass in the parent collection, to the ValidationRule instance (ie NameRule) that is doing the validation. Our xaml is

            <toolkit:DataGridTextColumn  Header="Name" Width="100"  >
                <toolkit:DataGridTextColumn.Binding  >
                    <Binding Path="Name" >
                        <Binding.ValidationRules>
                            <local:NameRule ValidationStep="UpdatedValue"/> 
                        </Binding.ValidationRules>
                    </Binding>
                </toolkit:DataGridTextColumn.Binding>
            </toolkit:DataGridTextColumn>
    

    There could be several ways to solve this, outside of the DataGrid, but I am trying to find the best method which utilises the WPF way of doing validation. BTW, I have reviewed the excellent article "WPF DataGrid Practical Examples" [^], and this addresses data validation. However the example provided is based on a DataTable as itemssource (in which case you can refer back to the DataTable), and it seems there should also be a way to use ObservableCollection as the itemssource. Any further suggestions would be appreciated. Tim

    WPF wpf question csharp help lounge

  • Reference to parent collection
    A ausadmin

    Dave, Thank you very much for your reply and for setting me in the right direction! Yes, you understood correctly - and your response crystalises the concerns I had about doing this. Thanks again. In fact the snippet posted was overly simplified - we already inherit from ObservableCollection and implement some Find and Sort methods, so we could override the Add method. What I am concerned about is a user editing the value to make it invalid, then being able to catch this scenario and alert the user. I know of many ways to do this, but I am trying to determine the best approach in WPF - so I will take this question to that forum (and in fact I have had the specific question on a relevant article for a few weeks but no reply). Your help is appreciated. Regards, Tim

    Visual Basic wpf question csharp help lounge

  • Reference to parent collection
    A ausadmin

    Apologies in advance, I suspect there may be an obvious answer to this, but I have searched these forums and google and not really been able to determine the solution. This is for a WPF application, but I think it is a more general programming question. We have an ObservableCollection(of T), where we need do do some validation of the member object, T. One of the rules is that a property of T (say name) cannot already exist in the collection. Our validation class is instantiated from the xaml, so I don't know of any way to pass in the reference to the ObservableCollection. However, this is needed to be able to step through the collection, to see if name has already been used, and report an error (if needed). One solution I can see is that the class T could have a property which is an ObservableCollection of T, and then you pass the parent collection into the member object. I think this will solve the issues, but something says to me this would be bad practise... Can anyone clarify whether this will cause errors or should be avoided? Can anyone suggest an alternative? More specifically, say we define Person

    Public Class Person
    Public Sub New(ByVal Name As String, ByVal People As ObservableCollection(Of Person))
    ...
    End Sub

    Public Property Name() As String
        ...
    End Property
    
    Public Property People() As ObservableCollection(Of Person)
        ...
    End Property
    

    End Class

    Then elsewhere make a collection of Person

        Dim MemberList As New ObservableCollection(Of Person)
        MemberList.Add(New Person("John", MemberList))
        MemberList.Add(New Person("Fred", MemberList))
        MemberList.Add(New Person("Jane", MemberList))
        MemberList.Add(New Person("Andrew", MemberList))
    

    Then we can bind say a WPF DataGrid to MemberList, and use validation to check our rule, to check that the Person name has not already been used in the ObservableCollection(of Person) - ie MemberList. The approach here will work, but I am concerned that there might be underlying problems - some circular reference or something (or else just not good practise). Thanks for any suggestions. Tim

    WPF wpf question csharp help lounge

  • Reference to parent collection
    A ausadmin

    Apologies in advance, I suspect there may be an obvious answer to this, but I have searched these forums and google and not really been able to determine the solution. This is for a WPF application, but I think it is a more general programming question. We have an ObservableCollection(of T), where we need do do some validation of the member object, T. One of the rules is that a property of T (say name) cannot already exist in the collection. Our validation class is instantiated from the xaml, so I don't know of any way to pass in the reference to the ObservableCollection. However, this is needed to be able to step through the collection, to see if name has already been used, and report an error (if needed). One solution I can see is that the class T could have a property which is an ObservableCollection of T, and then you pass the parent collection into the member object. I think this will solve the issues, but something says to me this would be bad practise... Can anyone clarify whether this will cause errors or should be avoided? Can anyone suggest an alternative? More specifically, say we define Person

    Public Class Person
    Public Sub New(ByVal Name As String, ByVal People As ObservableCollection(Of Person))
    ...
    End Sub

    Public Property Name() As String
        ...
    End Property
    
    Public Property People() As ObservableCollection(Of Person)
        ...
    End Property
    

    End Class

    Then elsewhere make a collection of Person

        Dim MemberList As New ObservableCollection(Of Person)
        MemberList.Add(New Person("John", MemberList))
        MemberList.Add(New Person("Fred", MemberList))
        MemberList.Add(New Person("Jane", MemberList))
        MemberList.Add(New Person("Andrew", MemberList))
    

    Then we can bind say a WPF DataGrid to MemberList, and use validation to check our rule, to check that the Person name has not already been used in the ObservableCollection(of Person) - ie MemberList. The approach here will work, but I am concerned that there might be underlying problems - some circular reference or something (or else just not good practise). Thanks for any suggestions. Tim

    modified on Tuesday, October 27, 2009 1:40 AM

    Visual Basic wpf question csharp help lounge

  • WPF: WPF Toolkit Datagrid. Capturing Key board events
    A ausadmin

    To learn about DataGrid, I suggest looking at "WPF DataGrid Practical Examples" [^]. To respond to the F9 key I expect you can use the KeyDown event, but I have not tried this. To handle such events in a MVVM pattern - that is tricky and not something I have solved. So far I have taken the easy path and simply used codebehind. I suspect the answer might be in "WPF : If Heineken did MVVM Frameworks Part 2 of n" [^] - View Lifecycle Events - but I have not yet properly followed this or tried it. I hope that might be helpful. Tim

    WPF csharp wpf question

  • RadioButton DataBinding, without code-behind
    A ausadmin

    I'm not sure if I totally understand your requirement, however you can certainly use MVVM to support a radio button list. Take a look at "Creating an Internationalized Wizard in WPF" [^], in particular the section "Presenting Options via OptionViewModel". In this example the OptionViewModel is used for CheckBox options and RadioButton options. BTW it can be extended for a Combobox - you will see my thread in the discussions for the article, and Karl's solution. I hope this helps. Tim

    WPF wpf question csharp wcf

  • WPF DataGrid with DataGridTemplateColumn and RadioButton
    A ausadmin

    I have posted the following question on codeplex, but not had any reply. I am hoping someone here may be able to help. I have a WPF DataGrid which represents a small number of options (ie one option per row), one of which is chosen as the default. In the first column of the DataGrid I want to have a RadioButton in each row - to set the default. I have almost got this to work with the code below - the Binding is working. The problem is, it is possible to get into a scenario where the setting from the RadioButton is lost. Our underlying object being bound to implements IEditableObject and we use this in various way to check edits and also take action when the default is changed. I have found that clicking the RadioButton completely bypasses the BeginEdit / EndEdit process of the DataGrid. The xaml is as follows:

                        <toolkit:DataGrid Name="dgTesters" AutoGenerateColumns="False" AlternationCount="2" ItemsSource="{Binding LocalTesters}" 
                                                  CanUserAddRows="false" CanUserDeleteRows="False"  
                                                  SelectionMode="Single" 
                                                  RowEditEnding="dgTesters\_RowEditEnding">
                            <toolkit:DataGrid.Columns>
                                <toolkit:DataGridTemplateColumn>
                                    <toolkit:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate >
                                            <RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
                                        </DataTemplate>
                                    </toolkit:DataGridTemplateColumn.CellEditingTemplate>
                                    <toolkit:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate >
                                            <RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
                                        </DataTemplate>
                                    </toolkit:DataGridTemplateColumn.CellTemplate>
                                </toolkit:DataGridTemplateColumn>
                                <toolkit:DataGridTextColumn Binding="{Binding TesterName}" Header="Tester Name" Width="\*" MinWidth="80" />
                                <!-- Further columns dele
    
    WPF wpf help csharp wcf question

  • Font difference between XP and Vista in wpf app
    A ausadmin

    We have a wpf app developed under windows XP SP2. When this app runs under Vista, the text gets clipped in many places - it is as though a different font is used which is slightly larger. I have seen this with both Tahoma and Arial. I could go through and add padding or miniumum height to solve the, but it seems as though that should not be necessary (and may lead to other problems). Has anyone else experienced this? Can anyone provide some advice or pointers? A sample style is as follows:

    <Style x:Key="Heading3" TargetType="{x:Type TextBlock}">
    <Setter Property="FontWeight" Value="Bold"/>
    <Setter Property="Foreground" Value="{DynamicResource textDimmedForegroundBrush}" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="FontFamily" Value="Arial"/>
    </Style>

    Thanks for any help, Tim

    WPF csharp wpf help question

  • UserControl does not assume height of parent container
    A ausadmin

    Mark, Thanks for the simple solution to this problem! I can see now that I needed to have a style with a control template to define the behaviour of the HeaderedContentControl. Reading the help page again, I can see I missed "A HeaderedContentControl has a limited default style. An application developer can create a HeaderedContentControl, but its appearance will be very simple." Note that we need to use a UserControl, to represent a number of more complex "pages", which are swapped in / out in code as the user steps through the wizard. That is why we need the user control rather than the simpler approach you presented. I will implement this back in our application and hopefully it will solve the original problem. Regards, Tim

    WPF wpf help csharp css dotnet

  • UserControl does not assume height of parent container
    A ausadmin

    I have been struggling with this issue for some time, and I have now constructed a simple example to demonstate the problem. I am not sure whether this is an issue with WPF or my lack of understanding. As part of our application, I have created a wizard along the lines of Creating an Internationalized Wizard in WPF. This uses the MVVM pattern and the various pages of the wizard are implemented in User Controls. The problem that I have is when the wizard window is resized, the UserControl does not take the height of the window. However it does take the width of the window. The result is that controls such as a list box, which the user may need to have resize with the window, do not resize. I have removed the complexity of our app, and created a very simple example with a window, that just contains a HeaderedContentControl, which contains the model for the UserControl. The window is

    <Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:UserControlDemo"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
    <DataTemplate DataType="{x:Type local:SimpleUserControlModel}">
    <local:SimpleUserControl />
    </DataTemplate>
    </Window.Resources>
    <Grid>
    <HeaderedContentControl Name="hcControl" Margin="20" Content="{x:Type local:SimpleUserControl}"
    Height="auto" Width="auto" VerticalContentAlignment="Stretch" />
    </Grid>
    </Window>

    Window code:

    Class Window1
    Private _simpleModel As SimpleUserControlModel

    Public Sub New()
    
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
    
        ' Add any initialization after the InitializeComponent() call.
        \_simpleModel = New SimpleUserControlModel
        hcControl.Content = \_simpleModel
    End Sub
    

    End Class

    User control:

    <UserControl x:Class="SimpleUserControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Grid>
    <Border Margin="5" BorderThickness="5" BorderBrush="Red" />
    </Grid>
    </UserControl>

    User control model:

    Public Class SimpleUserControlMod

    WPF wpf help csharp css dotnet

  • scroll ListBox to bottom in xaml
    A ausadmin

    I have been using the MVVM pattern extensively to build a UI (as in the great samples "WPF Apps With The Model-View-ViewModel Design Pattern"[^] and "Creating an Internationalized Wizard in WPF" [^]. This is a great technique for UI development, and I thank Josh Smith and Karl Shifflett for their postings and assistance in this area. While I have now got most of this working really well, I have hit a problem that I can't figure out how to solve in xaml or with data binding. I have a ListBox which I can add items to, but as the number of items exceeds the size of the ListBox, the items added at the bottom scroll out of view... I want to have the ListBox automatically scroll to display the last item. Can anyone tell me how to do this in xaml? I have reviewed several posts regarding use of the ScrollIntoView method, but I do not know how to access this from xaml (I think it may not be possible as its a method). As this is using the MVVM pattern, there is no way (that I am aware of) to access the ListBox instance from the code, to be able to call ScrollIntoView. Another solution would be to scroll to item n in xaml, which would be fine because I could then data bind to n. However I also have not been able to find a way to control the scrolling in xaml. I'm realy surprised there seems to be no easy way to do this in xaml. Any help would be greatly appreciated. Thanks, Tim

    WPF wpf design architecture help csharp
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups