The problem of designing the switching rules for piecewise affine systems which satisfy dwell time constraints is studied. With a proposed sampling-based approach which is different from existing traditional switching laws, the system can be updated and switched only at sampling instants. First, a sufficient condition for stability of piecewise linear affine systems converging to an invariant set is developed in the framework of the sampling-based switching, for which the lengths between successive sampling instants are assumed to be fixed. The corresponding sampled-based switching rules are obtained by solving a family of the linear matrix inequalities. Subsequently, these sampling lengths are extended from a fixed value to a certain interval and robust switching rules are obtained. Systems using these switching rules have the insensitivity to sampling period perturbation. Finally, an application to a DC-DC converter is provided to demonstrate the effectiveness of the proposed method.