Click here to Skip to main content
       

Silverlight / WPF

 
AnswerRe: WPF Extended Toolkit PropertyGrid - Turn off sorting? PinmvpAbhinav S27-Aug-12 2:56 
GeneralRe: WPF Extended Toolkit PropertyGrid - Turn off sorting? PinmvpJohn Simmons / outlaw programmer27-Aug-12 5:18 
QuestionDoes WPF propertyGrid support collection of items other than Enum? Pinmembersree140824-Aug-12 3:06 
AnswerRe: Does WPF propertyGrid support collection of items other than Enum? PinmemberMatt T Heffron24-Aug-12 9:10 
QuestionInvalidateMeasure doesn't trigger MeasureOverride call? PinmemberSledgeHammer0122-Aug-12 14:09 
AnswerRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinprotectorPete O'Hanlon22-Aug-12 14:21 
GeneralRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinmemberSledgeHammer0122-Aug-12 14:40 
GeneralRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinprotectorPete O'Hanlon23-Aug-12 0:53 
GeneralRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinmemberSledgeHammer0123-Aug-12 6:08 
GeneralRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinprotectorPete O'Hanlon23-Aug-12 6:15 
GeneralRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinmemberSledgeHammer0123-Aug-12 9:34 
GeneralRe: InvalidateMeasure doesn't trigger MeasureOverride call? PinmemberSledgeHammer0123-Aug-12 14:03 
QuestionWPF Problem With WrapPanel In ListBox.ItemsPanel [UPDATED] [modified] PinmemberKevin Marois20-Aug-12 15:33 
QuestionSwitch WPF UI at runtime PinmemberEd Hill _5_17-Aug-12 1:43 
I have a set of data that can be defined by the user, this will consist of item types i provide to them, for example (Text/Date/Decimal/Address/Lookup/Group). A group allows them to put related data together, groups can be nested as deep as the user requires. Think Composite pattern. As every user is able to create their own structure how it is best displayed will also vary from user to user.
 
I would like to be able to provide a mechanism that allows the user to select how they want their data displayed. To do this i have created a ResourceDictionary for each way of displaying the data but i've struggled to find a good way to implement switching between display methods. I have looked into switching the ResourceDictionary in code but could not find a good way to implement this. I've also thought about implementing a DataTemplateSelector and again struggled to get this working.
 
I tried creating empty interfaces (IShowAsTree, IShowAsTabs, IShowAsGroupBoxes), implementing them all in my view that holds the data, and casting when i return the property they are bound to.
 
public interface IBaseView{}
public interface IShowAsTree:IBaseView{}
public interface IShowAsTabs:IBaseView{}
public interface IShowAsGroupBoxes:IBaseView{}
 
public class DataCollection:BaseVM, IShowAsTree, IShowAsTabs, IShowAsGroupBoxes
{
    //extended data class
}
 
public class ExtenededDataView:BaseVM
{
    public String[] ViewAsOptions{get{return new[] {"Tree","Tabs","GroupBoxes"}}
 
    private String _viewAs;
    public String ViewAs
    {
        get {return _viewAs;}
        set
        {
            _viewAs = value;
            OnPropertyChanged(()=>View);
        }
    }
    private DataCollection _view;
    public IBaseView View
    {
        get
        {
            switch(ViewAs)
            {
                case "Tree":
                return _view as IShowTabs;
                break;
                //...
            }
        }
    }
}
 
This failed, should have known but DataTemplating appears to only work on classes not interfaces. This is when i decided on quite a hack for a solution, replace the interfaces with classes, and put a property in the parent class that holds the DataCollection. This works but feels wrong, so if any one can advice me of a better solution, or an area to research more it would be appreciated. Thanks to anyone who read this far, code was typed in so may well contain the odd error, but hopefully its enough to describe the problem.
 
Working Hack:
public class SwitchMyUI
    {
        public DataCollection Details { get; set; }
 
        public SwitchMyUI(DataCollection details)
        {
            Details = details;
        }
 
        public SwitchMyUI(SwitchMyUI copyFrom)
        {
            Details = copyFrom.Details;
        }
    }
 
    public class ShowTabs : SwitchMyUI
    {
        public ShowTabs(SwitchMyUI copyFrom) : base(copyFrom)
        {
        }
    }
 
    public class ShowTree : SwitchMyUI
    {
        public ShowTree(SwitchMyUI copyFrom) : base(copyFrom)
        {
        }
    }
 
Edit: Included WPF in the title
AnswerRe: Switch WPF UI at runtime PinmemberKenneth Haugland18-Aug-12 13:54 
GeneralRe: Switch WPF UI at runtime PinmemberEd Hill _5_19-Aug-12 0:45 
AnswerRe: Switch WPF UI at runtime PinmvpAbhinav S18-Aug-12 19:31 
GeneralRe: Switch WPF UI at runtime PinmemberEd Hill _5_19-Aug-12 22:57 
AnswerRe: Switch WPF UI at runtime PinprotectorPete O'Hanlon20-Aug-12 1:48 
QuestionWPF ListBox Question PinmemberKevin Marois15-Aug-12 16:22 
AnswerRe: WPF ListBox Question PinmemberEd Hill _5_15-Aug-12 23:07 
GeneralRe: WPF ListBox Question PinmemberKevin Marois16-Aug-12 7:10 
QuestionComboBox Dropdown Problem [modified] PinmvpJohn Simmons / outlaw programmer15-Aug-12 5:49 
AnswerRe: ComboBox Dropdown Problem PinprotectorPete O'Hanlon15-Aug-12 6:12 
GeneralRe: ComboBox Dropdown Problem PinmvpJohn Simmons / outlaw programmer15-Aug-12 6:13 
GeneralRe: ComboBox Dropdown Problem PinmvpJohn Simmons / outlaw programmer15-Aug-12 6:17 
GeneralRe: ComboBox Dropdown Problem PinmvpJohn Simmons / outlaw programmer15-Aug-12 7:45 
AnswerRe: ComboBox Dropdown Problem PinprotectorPete O'Hanlon15-Aug-12 23:59 
GeneralRe: ComboBox Dropdown Problem PinmvpJohn Simmons / outlaw programmer16-Aug-12 2:27 
GeneralRe: ComboBox Dropdown Problem PinprotectorPete O'Hanlon16-Aug-12 2:46 
GeneralRe: ComboBox Dropdown Problem PinmvpJohn Simmons / outlaw programmer17-Aug-12 5:05 
GeneralPut Blu-ray movies on New iPad and keep the file size around 2GB Pinmemberhihjay114-Aug-12 20:07 
QuestionHow to got Phone Number PingroupVikash Yadav14-Aug-12 17:29 
AnswerRe: How to got Phone Number PinprotectorPete O'Hanlon14-Aug-12 23:20 
AnswerRe: How to got Phone Number PinmvpAbhinav S15-Aug-12 0:08 
QuestionNeed to call third party API from SL 5 Solution PinmemberTbhavesh14-Aug-12 10:03 
AnswerRe: Need to call third party API from SL 5 Solution PinmemberWes Aday14-Aug-12 10:47 
AnswerRe: Need to call third party API from SL 5 Solution PinmemberAnumeha Shukla16-Aug-12 3:49 
QuestionCrop and save image in oval shape using silverlight PinmemberAnupbala13-Aug-12 20:20 
AnswerRe: Crop and save image in oval shape using silverlight PinprotectorPete O'Hanlon14-Aug-12 0:04 
QuestionWPF ComboBox Binding Problem PinmemberKevin Marois12-Aug-12 11:51 
AnswerRe: WPF ComboBox Binding Problem PinprotectorPete O'Hanlon12-Aug-12 12:22 
GeneralRe: WPF ComboBox Binding Problem PinmemberKevin Marois12-Aug-12 12:40 
GeneralRe: WPF ComboBox Binding Problem PinprotectorPete O'Hanlon13-Aug-12 5:08 
GeneralRe: WPF ComboBox Binding Problem PinmemberKevin Marois12-Aug-12 12:47 
AnswerRe: WPF ComboBox Binding Problem PinmemberCollin Jasnoch13-Aug-12 4:20 
QuestionTreeView Control Item Styling PinmemberAndy_L_J12-Aug-12 3:38 
AnswerRe: TreeView Control Item Styling PinmemberSledgeHammer0113-Aug-12 11:25 
GeneralGroupbox visibility problem in WPF after debugging and changing the combobox value Pinmemberkarthik bandaru9-Aug-12 0:24 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value PinmemberEd Hill _5_9-Aug-12 1:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 27 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid